ID: 49701 Updated by: [email protected] Reported By: applezinc at gmail dot com -Status: Open +Status: Bogus Bug Type: Math related Operating System: slackware linux 12.2 PHP Version: 5.2.11 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php . Previous Comments: ------------------------------------------------------------------------ [2009-09-28 19:21:23] [email protected] Thank you for your bug report. The techical reason this works like this is as follows: rand() takes two integers. When you specify a number bigger than 2^31, it is cast to float. When it is passed to rand(), it is cast to an int. The number 4294967294 then becomes -2. ------------------------------------------------------------------------ [2009-09-28 17:31:31] applezinc at gmail dot com Description: ------------ getrandmax is 2^31. if you put in a number for max greater than that (as the documentation says you can), the function always returns the min. mt_rand is the same. Reproduce code: --------------- echo rand(1,4294967294); echo "\n"; echo getrandmax(); echo "\n"; Expected result: ---------------- random number between 1 and 4294967294. Actual result: -------------- 1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49701&edit=1
