#27919 [Opn->Csd]: [chm and php.net] bug on function.rand.html
| From: | irchtml@php.net | Date: | Thu, 08 Apr 2004 15:07:07 +0000 |
| Subject: | #27919 [Opn->Csd]: [chm and php.net] bug on function.rand.html | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969359985@lists.php.net to get a copy of this message | ||
ID: 27919
Updated by: irchtml@php.net
Reported By: kingoleg at mail dot ru
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: windows
PHP Version: 4.3.4
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
RAND_MAX is [about] 32768 on windows. 'echo getrandmax()' should give
you that value. That is the value used for the 'max' argument _if one
is not specified_. That's not to say a larger max cannot be used,
RAND_MAX is the default. As the manual says, "If called without the
optional min, max arguments rand() returns a pseudo-random integer
between 0 and RAND_MAX."
The note was a bit deceiving as it is entirely possible to specify a
range much larger than 32768.
Previous Comments:
------------------------------------------------------------------------
[2004-04-08 07:30:50] kingoleg at mail dot ru
Description:
------------
I have found a bug on page
http://www.php.net/manual/en/function.rand.php
[chm date: 2003-09-06]:
"On some platforms (such as Windows) RAND_MAX is only 32768. If you
require a range larger than 32768, consider using mt_rand() instead."
It is not correct for example on WinXp.
Reproduce code:
---------------
<?php
echo rand(11111111111111,222222222222222222);
?>
Expected result:
----------------
first run:
127534874 (it is >larger than 32768)
second run
59053744 (it is >larger than 32768)
Actual result:
--------------
I think, that word "range" in this note is from early PHP version, when
syntax was rand(start, rand). Now it rand(start, end).
I think, that words "such as Windows" must be replaced with "such as
early versions of Windows".
Or, this note can be fully rewrited.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27919&edit=1