ID:               43171
 User updated by:  bdew at druzya dot org
 Reported By:      bdew at druzya dot org
 Status:           Open
 Bug Type:         Math related
 Operating System: windows xp sp2
 PHP Version:      5.2.4
 New Comment:

Err, sory...

"If i use rand(x,y) the bug does happen only when
max_rand+2>y>max_rand+2"

should have read 

"If i use rand(x,y) the bug does happen only when
max_rand+2>y>max_rand-2"


Previous Comments:
------------------------------------------------------------------------

[2007-11-01 13:30:23] bdew at druzya dot org

Description:
------------
Under windows xp cli version, rand() seems to return cycling values in
lower bits.

If i use rand(x,y) the bug does happen only when
max_rand+2>y>max_rand+2

mt_rand() is unaffected

Tested same code under linux cli and the bug doesn't happen.

possibly related to http://bugs.php.net/bug.php?id=43108

Reproduce code:
---------------
$a=rand() & 0xff;
for ($k=0;$k<10;$k++) {
        $i=0;
        do {
                $i++;
                $b=rand() & 0xff;
        } while ($a!=$b);
        echo("cycle: $i\n"); 
};

Expected result:
----------------
10 lines with "cycle: x", x being different every line

Actual result:
--------------
cycle: 256
cycle: 256
cycle: 256
cycle: 256
cycle: 256
cycle: 256
cycle: 256
cycle: 256
cycle: 256
cycle: 256

every time


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43171&edit=1

Reply via email to