How random is rand(), and is there a solution for generating more random numbers?
+6
A:
How about mt_rand()
, which uses the Mersenne Twister. It should generate random numbers up to the size of an int. (use mt_getrandmax()
to get the maximum value).
Dmitry Brant
2009-07-28 14:56:40
+2
A:
There is a better random number generator (which is referenced in the 'see also
' section of the documentation of rand()
, by the way): mt_rand()
soulmerge
2009-07-28 14:57:10
Slower - really? docs say its 4 times faster: "... which will produce random numbers four times faster than what the average libc `rand()` provides."
Dominic Rodger
2009-07-28 15:00:47
Woops, sorry. Fixed the answer.
soulmerge
2009-07-28 15:06:58
A:
You can use this function from the mt_rand notes in the function documentation http://www.php.net/manual/en/function.mt-rand.php#83358
inakiabt
2009-07-28 19:32:04