note 28724 added to function.rand
| From: | Antonio at rack1 dot php dot net | Date: | Wed, 22 Jan 2003 13:07:31 +0000 |
| Subject: | note 28724 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42585@lists.php.net to get a copy of this message | ||
This function has partially (and undocumentally) changed its behaviour.
On PHP 4.0.6 (i586 Linux), the call
rand(1,4294967295)
(that's 2^32-1) gives random values in the specified range, while on PHP 4.2.3 (i586 Linux) the
same call always returns a 1 (one) value. In this case the maximum value that can be used with a
readable behaviour is
rand(1,2147483647)
(that's 2^31-1).
It seems that the last argument is now interpreted as a signed int, while it was not before. In
fact, other values into the 2147483647-4294967295 range seems to be "wrapped" into
negative integers.
--
http://www.php.net/manual/en/function.rand.php
http://master.php.net/manage/user-notes.php?action=edit+28724
http://master.php.net/manage/user-notes.php?action=delete+28724
http://master.php.net/manage/user-notes.php?action=reject+28724