Edit report at https://bugs.php.net/bug.php?id=45184&edit=1
ID: 45184
Updated by: cmb@php.net
Reported by: kala at sankya dot com
Summary: algorithm to limit random numbers to a certain range
is flawed
-Status: No Feedback
+Status: Open
Type: Bug
Package: Math related
-Operating System: Linux
+Operating System: *
-PHP Version: 5.2.6
+PHP Version: 5.6.11
Assigned To: pajoye
Block user comment: N
Private report: N
New Comment:
Indeed, as pointed out by the reporter, RANGE_RANDOM() is flawed.
The new CSPRNG function random_int() seems to get the scaling
right[1].
[1] <https://github.com/php/php-src/blob/php-7.0.0beta2/ext/standard/random.c#L184-L197>
Previous Comments:
------------------------------------------------------------------------
[2015-08-05 12:09:46] cmb@php.net
Related To: Bug #45301
------------------------------------------------------------------------
[2013-02-18 00:33:55] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
------------------------------------------------------------------------
[2010-05-21 12:14:13] mike@php.net
Should probably be in feedback state.
------------------------------------------------------------------------
[2008-06-18 16:21:40] pajoye@php.net
Would you be interested in improving our code?
------------------------------------------------------------------------
[2008-06-05 11:49:10] kala at sankya dot com
Sorry the line
int val = (i/divisor)*10;
in the example program should be :
int val = (i/divisor)*REQUESTED_RANGE;
for the program to work correctly for any other range other than 10.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=45184
--
Edit this bug report at https://bugs.php.net/bug.php?id=45184&edit=1