+

PHP Gmp_pow () function

Syntax:
gmp_pow ($base, $exp)
Parameters:The function takes two required parameters $base and $exp.
  • $base - this is the base number. This parameter can be a GMP object in PHP 5.6 and above, or we are also allowed to pass a numeric string, provided that the string can be converted to a number.
  • $exp - it is the force that rises to the bottom
  • Returned value:this function returns a positive GMP number equivalent to $base $exp Examples:
    Input: $base = "2" $exp = 2 Output: 4 Input: $base = "0" $exp = 0 Output: 1
    The programs below illustrate gmp_pow() function:Program 1:The program below demonstrates the gmp_pow() function when a GMP number is passed as an argument.
    // PHP program for calculating the raised power
    // to number 
    // GMP number as an argument $base = gmp_init ( "100" , 2); $exp = 2;  
    // function calculates Pow raised to
    // number $pow = gmp_pow (< / code> $base , $exp ); // 4 ^ 2 
    // gmp_strval Convert GMP number to string
    // view in a given base (default 10). echo gmp_strval ( $pow , 2). "" ; ?>
    Output:
    10000  Program 2:The program below demonstrates gmp_pow() when a numeric string is passed as an argument.      
    // PHP program for calculating the raised power
    // to the number 
    // numeric string as argument $base = "4" ; $exp = 2;  
    // function calculates Pow raised to
    // number 4 ^ 2 $pow = gmp_pow ( $base , $exp ); echo $pow ; ?>
    Output:
    10000  Link:
    http://php.net/ manual / en / function.gmp-pow.php
    Get Solution for free from DataCamp guru