go to bug id or search bugs for
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.
Warning: gmp_pow() expects parameter 2 to be long, resource given in Command line
code on line 1
Add a Patch
Add a Pull Request
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
In 5.2 what happens is that the resource id is converted to long. Which is not the expected behavior in many cases. i.e. it does not uses the gmp value as might looks like.
var_dump($b); // resource(5) of type (GMP integer)
$c=gmp_pow($a,5); // equal to below
So consider the 5.3+ version as alerting about this false positive cases.