PHP - gmp_powm() Function
Definition and Usage
The gmp_powm() function returns the new number with the given number raised to the power along with modulo.
Description
The gmp_powm() function will return a new GMP number where the given number raised to the power and also the modulo.
Syntax
gmp_powm ( GMP $base , GMP $exp , GMP $mod ) : GMP
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
base The base number.It can a GMP resource number , a gmp object or a numeric string. |
| 2 |
exp The positive power to raise the base.If negative value is used ,the function will return undefined. |
| 3 |
mod The modulo. |
Return Values
PHP gmp_powm() function returns a new GMP rnumber that is calcuated based on the given base number, exp and mod.
PHP Version
This function will work from PHP Version greater than 5.0.0.
Example 1
Working of gmp_powm() −
<?php
$num = gmp_powm("12", "21", "2147");
echo "The result is : ".gmp_strval($num);
?>
This will produce following result −
The new number is : 1766
Example 2
Working of gmp_powm() −
<?php
$num = gmp_powm("121", "21", "8162147");
echo "The new number is : ".$num;
?>
This will produce following result −
The new number is : 344023
php_function_reference.htm
Advertisements