Bug->Req #52167 [Opn]: gmp_pow does not accept gmp values
| From: | kalle@php.net | Date: | Thu, 24 Jun 2010 16:03:58 +0000 |
| Subject: | Bug->Req #52167 [Opn]: gmp_pow does not accept gmp values | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-151844@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52167&edit=1
ID: 52167
Updated by: kalle@php.net
Reported by: mark at hell dot ne dot jp
Summary: gmp_pow does not accept gmp values
Status: Open
-Type: Bug
+Type: Feature/Change Request
Package: GNU MP related
Operating System: Linux
PHP Version: 5.3.2
New Comment:
PHP 5.3 introduced unified parameter parsing, whereas in 5.2 there were
alot of places manually converting types that were not compatible.
gmp_pow()'s $exp parameter converted to an integer (long) no matter what
type it had passed. In 5.3+ it was changed to require stricly to be
compatible types to do type convertion.
However I do not know the exact design reason for why you cannot pass an
resource and only a long, so I've changed this to be a feature request
Previous Comments:
------------------------------------------------------------------------
[2010-06-24 09:39:19] mark at hell dot ne dot jp
Description:
------------
gmp_pow throws a "expects parameter 2 to be long" error when passed a
gmp value.
Works nicely with PHP 5.2.x but not with PHP 5.3.
I am doing some maths for encryption with php which use large integers
and I have
to compute pow(a,b) with both values being large integers (~512 bits).
I'm opening this bug so we can investigate why gmp_pow() has been
modified to
only accept integers as second argument, and if there is no good reason
make it
accept gmp values again.
My guess is this change was done on the PHP_5_2 branch but not ported to
PHP_5_3.
Unfortunately svn blame couldn't fetch anything interesting to know why
this
became like this.
Test script:
---------------
$a=gmp_init(48974);
$b=gmp_init(55);
$c=gmp_pow($a,$b);
var_dump(gmp_intval($c));
Expected result:
----------------
int(7944261659914959072)
Actual result:
--------------
Warning: gmp_pow() expects parameter 2 to be long, resource given in
Command line
code on line 1
int(0)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52167&edit=1