#35662 [Opn->Fbk]: The 'rand()' function returns only few different values
| From: | sniper@php.net | Date: | Tue, 13 Dec 2005 19:58:13 +0000 |
| Subject: | #35662 [Opn->Fbk]: The 'rand()' function returns only few different values | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-90389@lists.php.net to get a copy of this message | ||
ID: 35662
Updated by: sniper@php.net
Reported By: jullrich at sans dot org
-Status: Open
+Status: Feedback
Bug Type: *Math Functions
Operating System: Linux 2.6 (RedHat)
PHP Version: 4.4.1
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.1-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.1-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2005-12-13 20:53:53] jullrich at sans dot org
Description:
------------
The 'rand' function is far from random. For example, the
following code:
<?= rand(10000000000,99999999999); ?>
only generates values that start with '12','13' or '14'.
Out of 1500 times the function is called, only approx. 1000 different
values are generated.
Reproduce code:
---------------
<?= rand(10000000000,99999999999); ?>
Expected result:
----------------
somewhat random numbers between 10000000000 and 99999999999.
Actual result:
--------------
all numbers are in the range from 120000000000 to 150000000000 and
frequently repeat (about 25% of the numbers
are repeats).
Sample:
1379409636
1275750426
1248288483
1398136354
1404047798
1292410973
1405794269
1278267510
1225653649
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35662&edit=1