Re:Computer Random vs. True Random : See the difference in h...
by jbyers on Tuesday May 20, 2008 @04:41PM
(#195286)
As the author points out, php's rand function is garbage on some systems. mt_rand (based on the Mersenne twister) has been the suggested replacement for many years; it's built in, fast, and consistent across platforms.
[ Parent
| on HN ]
Re:Computer Random vs. True Random : See the difference in h...
by lux on Tuesday May 20, 2008 @06:07PM
(#195373)
Indeed, the first thing I thought was "hey that's PHP! Oh, did he just use rand()?" It ought to be common knowledge in the PHP world that you always use mt_rand().
On OSX, the results aren't very noticeable, probably because the underlying libs are higher quality than Windows, but mt_rand() definitely produces something comparable to his random.org image.
Not sure why rand() isn't simply replaced with mt_rand() under the hood, since improving randomness will hardly break b/c... Maybe PHP9 will have that ;)