#40187 [Opn->Bgs]: mt_rand(), rand()
| From: | iliaa@php.net | Date: | Sun, 21 Jan 2007 19:10:58 +0000 |
| Subject: | #40187 [Opn->Bgs]: mt_rand(), rand() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-107841@lists.php.net to get a copy of this message | ||
ID: 40187
Updated by: iliaa@php.net
Reported By: callawey at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: windows xp
PHP Version: 5.2.0
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
Integer overflow on 32 bit systems is the cause.
Previous Comments:
------------------------------------------------------------------------
[2007-01-21 19:06:47] callawey at gmail dot com
Description:
------------
rand and mt_rand generates random lenght integer between -9999999999
and +9999999999.
example mt_rand(100000000000, 999999999999);
outputs: -564, -688852, 5586666988, -68889558
Reproduce code:
---------------
$str = mt_rand(100000000000, 999999999999);
Expected result:
----------------
positive numbers between 100000000000 and 999999999999
Actual result:
--------------
-492911349,1162038978,-219333642
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40187&edit=1