#33556 [Opn->Bgs]: rand is not random !!!. Random number repeat every 32768 time .

From: Date: Sun, 03 Jul 2005 18:46:20 +0000
Subject: #33556 [Opn->Bgs]: rand is not random !!!. Random number repeat every 32768 time .
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81319@lists.php.net to get a copy of this message
ID: 33556 Updated by: helly@php.net Reported By: toslava at gmail dot com -Status: Open +Status: Bogus Bug Type: *Math Functions Operating System: windows 2003 PHP Version: 5.0.4 New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Ask Microsoft, php just wraps a windows api function. Previous Comments: ------------------------------------------------------------------------ [2005-07-03 20:31:59] toslava at gmail dot com 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 this bug report at http://bugs.php.net/?id=33556&edit=1

« previous php.bugs (#81319) next »