php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70575 gmp_random() doc wrong
Submitted: 2015-09-24 20:40 UTC Modified: 2018-07-02 15:50 UTC
From: rainer dot jung at kippdata dot de Assigned: nikic (profile)
Status: Closed Package: GNU MP related
PHP Version: 7.0.0RC3 OS: Any
Private report: No CVE-ID: None
 [2015-09-24 20:40 UTC] rainer dot jung at kippdata dot de
Description:
------------
Docs at http://php.net/manual/en/function.gmp-random.php say:

Generate a random number. The number will be between zero and the number of bits per limb multiplied by limiter.
...
Generally, the number of bits in a limb is either 16 or 32, but this is not guaranteed. 


The errors are:

- "number of bits per limb multiplied by limiter" is not the upper boundary of the random number, instead it is 2**n-1, where n is "number of bits per limb multiplied by limiter"
- number of bits in a limb is in most cases 64 or 32, not 32 or 16.


Suggested correction (partly taken from docs of gmp_random_bits()):

Generate a random number. The number will be between 0 and (2 ** n) - 1, where n is the number of bits per limb multiplied by limiter.
 
...
Generally, the number of bits in a limb is either 64 or 32, but this is not guaranteed.


If you mind: where are the sources for the man pages (git URL or similar)? I could then attach a patch.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-24 04:45 UTC] kalle@php.net
Hi

The source pages for the PHP documentation are in SVN and can be found under:
http://svn.php.net/

In the 'phpdoc' namespace, and 'en/reference/gmp' for GMP.

We do have a more convinent online editor at:
http://edit.php.net/

You can use for quick submission for review.

Thanks for the contribution! :)
 [2017-01-28 17:46 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem -Package: Documentation problem +Package: GNU MP related
 [2018-07-02 15:49 UTC] nikic@php.net
Automatic comment from SVN on behalf of nikic
Revision: http://svn.php.net/viewvc/?view=revision&revision=345264
Log: Fix bug #70575: gmp_random() doc wrong

Implement the changes suggested by the reporter.
 [2018-07-02 15:50 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2020-02-07 06:05 UTC] phpdocbot@php.net
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=c035f0005ac3bfc38d9efed218d763329e0c0fd3
Log: Fix bug #70575: gmp_random() doc wrong
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC