php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #50942 gmp_strval() only allows base 2 to 36
Submitted: 2010-02-05 20:22 UTC Modified: 2010-02-19 07:55 UTC
From: php dot devel at homelinkcs dot com Assigned: kalle (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.2.12 OS: GNU/Linux
Private report: No CVE-ID: None
 [2010-02-05 20:22 UTC] php dot devel at homelinkcs dot com
Description:
------------
The manual says that as of PHP 5.2.12, the range for the base argument to gmp_strval() was extended from 2 to 36, to 2 to 62 and -2 to -36.  However, in my tests only 2 to 26 worked.

Reproduce code:
---------------
foreach (array_merge(range(-2, -36), range(2, 62)) as $num) {
	if (@gmp_strval(gmp_init(62), $num)) echo "Base $num: GOOD\n";
	else echo "Base $num: BAD\n";
}

Expected result:
----------------
gmp_strval() should return a value for all bases in specified range.

Actual result:
--------------
gmp_strval() fails to return a value and gives warning, "Bad base for conversion", for bases -2 to -36 and 27 to 62.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-05 20:26 UTC] php dot devel at homelinkcs dot com
Sorry, s/26/36/ in second sentence and s/27/37/ in last sentence.
 [2010-02-17 05:35 UTC] kalle@php.net
What version of GMP is PHP compiled against? For the extended range to be possible, you must be using GMP 4.2 or greater
 [2010-02-17 18:32 UTC] php dot devel at homelinkcs dot com
I have GMP 4.3.2.

Also, I just tested this on another system with PHP 5.3.1 linked against GMP 4.3.1 and got the same result.
 [2010-02-19 07:55 UTC] svn@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=295245
Log: Fixed bug #50942 (gmp_strval() only allows base 2 to 36)
 [2010-02-19 07:55 UTC] kalle@php.net
-Status: Open
+Status: Closed
-Assigned To: 
+Assigned To: kalle

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.

Seems like GMP changes never was merged to 5.3.1 (in 5.2.12 it was removed [1]), but they are available according to the source in 5.3.2 [2][3].

[1] http://svn.php.net/viewvc?view=revision&revision=291336
[2] http://svn.php.net/viewvc?view=revision&revision=291362
[3] http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3_2/ext/gmp/gmp.c?r1=291323&r2=291362

I've updated the relevant ChangeLog information for both gmp_init() and gmp_strval() to reflect this change.
 [2020-02-07 06:09 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=34fe6dd1e05db8026bf4c2c9cef2706dbf2efb14
Log: Fixed bug #50942 (gmp_strval() only allows base 2 to 36)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 15:00:01 2026 UTC