#33556 [NEW]: rand is not random !!!. Random number repeat every 32768 time .

From: Date: Sun, 03 Jul 2005 18:32:00 +0000
Subject: #33556 [NEW]: rand is not random !!!. Random number repeat every 32768 time .
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81318@lists.php.net to get a copy of this message
From: toslava at gmail dot com Operating system: windows 2003 PHP version: 5.0.4 PHP Bug Type: *Math Functions Bug description: rand is not random !!!. Random number repeat every 32768 time . Description: ------------ rand is not random !!!. Random number repeat every 32768 time :-((( _ 0 _ _ 8512030 _ _ 1 _ _ 5655227 _ _ 2 _ _ 6934082 _ _ 3 _ _ 2293270 _ ....... _ 32768 _ _ 8512030 _ _ 32769 _ _ 5655227 _ _ 32770 _ _ 6934082 _ _ 32771 _ _ 2293270 _ ...... Reproduce code: --------------- echo '<pre>'; for ($i=0; $i<160000; $i++) { $ch01=rand(900000, 9999999); echo " _ $i _ \t _ $ch01 _ \n"; } Expected result: ---------------- ..... realy random number ! Actual result: -------------- _ 0 _ _ 8512030 _ _ 1 _ _ 5655227 _ _ 2 _ _ 6934082 _ _ 3 _ _ 2293270 _ ....... _ 32768 _ _ 8512030 _ _ 32769 _ _ 5655227 _ _ 32770 _ _ 6934082 _ _ 32771 _ _ 2293270 _ ...... -- Edit bug report at http://bugs.php.net/?id=33556&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33556&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33556&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33556&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33556&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33556&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33556&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33556&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33556&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33556&r=support Expected behavior: http://bugs.php.net/fix.php?id=33556&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33556&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33556&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33556&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33556&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33556&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33556&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33556&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33556&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33556&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33556&r=mysqlcfg

« previous php.bugs (#81318) next »