note 21052 added to function.srand
| From: | office at at universalmetropolis dot com | Date: | Fri, 26 Apr 2002 18:40:44 +0000 |
| Subject: | note 21052 added to function.srand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29884@lists.php.net to get a copy of this message | ||
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
http://master.php.net/manage/user-notes.php?action=edit+21052
http://master.php.net/manage/user-notes.php?action=delete+21052
http://master.php.net/manage/user-notes.php?action=reject+21052