ID:               35662
 User updated by:  jullrich at sans dot org
 Reported By:      jullrich at sans dot org
-Status:           Feedback
+Status:           Open
 Bug Type:         *Math Functions
 Operating System: Linux 2.6 (RedHat)
 PHP Version:      4.4.1
 New Comment:

Getting the same problem with the php 5.1-latest.

Code used to test:
<?=

#    1234567890 1234567890
rand(1000000000,9999999999);

?>

Wrapper to generate 100 numbers:

for b in `seq 1 100`; do php -e x.php >> numbers; done

Quick summary of first two digits:
10... 21 times
11... 21 times
12... 13 times
13... 24 times
14...  3 times

so still the same problem. Only numbers from 10... to 14... are
generated.


Previous Comments:
------------------------------------------------------------------------

[2005-12-13 20:58:11] [EMAIL PROTECTED]

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



------------------------------------------------------------------------

[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

Reply via email to