ID: 24050 Updated by: [EMAIL PROTECTED] Reported By: ptchristendom at yahoo dot com Status: Open -Bug Type: Unknown/Other Function +Bug Type: *General Issues -Operating System: Win XP Pro +Operating System: win32 only (?) -PHP Version: 4CVS-2003-06-05 (stable) +PHP Version: 4.3.3-dev New Comment:
Can not reproduce within Linux, must be some windows only issue.. Previous Comments: ------------------------------------------------------------------------ [2003-06-05 18:15:50] ptchristendom at yahoo dot com The function mt_rand() has a "preference" for the value 1898087491 for a majority (but not all) of the default seedings. As a result, if you don't seed it you will generate far too many collisions on the value 1898087491. If you seed it with values such as 0, 1, 2, 3, etc., the problem will not occur (these are all the seeds that I tried); however, the mt_rand should work properly when not seeded. Further, there SHOULD NOT be any single seed that causes this value to occur more than others. This leads me to believe that mt_rand() is not implemented correctly when not seeded. Here it says that it is not necessary to use mt_srand() to obtain "random" data: http://us3.php.net/manual/en/function.mt-srand.php --------------------------------------------------------- The following shows a test script that reproduces the problem: D:\php4-win32-STABLE-200306052030>type unseeded2.php <? for ($i = 0; $i < 25; $i++) print `php -q unseeded.php`."\n"; ?> D:\php4-win32-STABLE-200306052030>type unseeded.php <? $j = 0; for ($i = 0; $i < 65536; $i++) if (mt_rand() == 1898087491) $j++; print $j; ?> D:\php4-win32-STABLE-200306052030>php unseeded2.php Content-type: text/html X-Powered-By: PHP/4.3.3-dev 36480 39710 2308 41576 38524 39247 5005 5449 38011 29808 37577 5738 46785 42418 45619 42322 39296 15909 35019 39127 26830 37223 33348 22713 0 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24050&edit=1