note 21052 modified in function.srand by cece
| From: | cece@php.net | Date: | Tue, 30 Mar 2004 14:12:47 +0000 |
| Subject: | note 21052 modified in function.srand by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67382@lists.php.net to get a copy of this message | ||
[Editor's note: 1234567 is NOT a prime number]
I created an application that requires millions of different random values replicating dice and have
found over substantial time, the numbers even up towards the middle.
May I suggest rather than this:
(double)microtime()*1000000
Use this instead:
(double)microtime()*1234567
1000000 is an even number, divisible by almost anything. 1234567 is a prime number and is hence
uneven so it gives a little more flexibility with range.
Don't know if this change was the main reason for affecting the application, but it seemed to
help.
--was--
I created an application that requires millions of different random values replicating dice and have
found over substantial time, the numbers even up towards the middle.
May I suggest rather than this:
(double)microtime()*1000000
Use this instead:
(double)microtime()*1234567
1000000 is an even number, divisible by almost anything. 1234567 is a prime number and is hence
uneven so it gives a little more flexibility with range.
Don't know if this change was the main reason for affecting the application, but it seemed to
help.
http://www.php.net/manual/en/function.srand.php