php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #55446 getrandmax() incorrectly defined on rand() page
Submitted: 2011-08-18 04:44 UTC Modified: 2011-08-18 12:57 UTC
From: danielklein at airpost dot net Assigned: rquadling (profile)
Status: Closed Package: Website problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: danielklein at airpost dot net
New email:
PHP Version: OS:

 

 [2011-08-18 04:44 UTC] danielklein at airpost dot net
Description:
------------
getrandmax() returns 32767 on my Windows system, not 32768 as documented. This makes sense as 32767 is the highest unsigned 15 bit number. Also, setting min and max, while affecting the range, does not affect the granularity. The result of rand(0, 0x7FFF00) will always be a multiple of 256 (0x100). This should be noted as I was trying to use rand() to produce more than 32767 unique values. Please make a note in the rand() page that mt_rand() produces more unique values in this case.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-18 12:56 UTC] rquadling@php.net
Automatic comment from SVN on behalf of rquadling
Revision: http://svn.php.net/viewvc/?view=revision&revision=315138
Log: getrandmax returns 2^15 - 1, not 2 ^ 15 on Windows (and maybe others).
Fix bug #55446
 [2011-08-18 12:57 UTC] rquadling@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: rquadling
 [2011-08-18 12:57 UTC] rquadling@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.
 [2020-02-07 06:08 UTC] phpdocbot@php.net
Automatic comment on behalf of rquadling
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=5a4fe9cb9a978f1a2bdfd7182835a59769d3ab34
Log: getrandmax returns 2^15 - 1, not 2 ^ 15 on Windows (and maybe others). Fix bug #55446
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 18:01:30 2024 UTC