View Issue Details

IDProjectCategoryView StatusLast Update
12248Feature requestsExpression Managerpublic2019-09-07 10:58
Reporterjelo Assigned To 
Status newResolutionopen 
Summary12248: Expose php mt_rand to Expression manager
DescriptionThe rand() is not a very good PRNG.
Please add mt_rand to Expression manager.

A change of rand() (EM) to use mt_rand (PHP) would be possible too, but might would add compatibility issues when comparing old and new results.
TagsNo tags attached.


related to 15246 closedDenisChenu Allow fixed function (no js, only PHP) in expression mùanager 




2017-04-04 00:34

developer   ~43374

7.1.0 rand() has been made an alias of mt_rand().
7.1.0 mt_rand()has been updated to use the fixed, correct, version of the Mersenne Twister algorithm. To fall back to the old behaviour, use mt_srand() with MT_RAND_PHP as the second paramter.

But for js : use Math.random or another ?


2017-04-04 09:38

partner   ~43376

Was there a time when rand() was not using PHP?
I still wonder why manual examples stating {floor(rand(1,6.9999))}. The purpose of floor is unclear when rand() output is always integer. The 6.9999 as a parameter for php rand() is not needed.


2017-04-04 10:08

partner   ~43378

The rand() JS for rand() PHP was this, right?

function rand (min, max) {
    var args = arguments.length;
    if (args === 0) {
        min = 0;
        max = 32768;
        return Math.floor( Math.random() * (max - min + 1) ) + min;

MT implementations for JS are available. But choosing the right one might be a bigger task.

I'm really surprised that no rand() compatibility is maintained for PHP 7.1.

Issue History

Date Modified Username Field Change
2017-04-03 12:11 jelo New Issue
2017-04-04 00:34 DenisChenu Note Added: 43374
2017-04-04 09:38 jelo Note Added: 43376
2017-04-04 10:08 jelo Note Added: 43378
2019-09-07 10:58 DenisChenu Relationship added related to 15246