Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

gmp_pow

Description

The gmp_pow of GMP for PHP raises a number to a power.

Syntax

gmp_pow(
    GMP|int|string $num,
    int $exponent
): GMP

Parameters

num

The base number.

A GMP object, an int or a numeric string.

exponent

The positive power to raise the num.

Return

Returns the new (raised) number, as a GMP number.

The case of 0^0 yields 1.

Examples

1 · num · GMP · exponent

<?

$num = 2;
$exponent = 3;

$num = gmp_init($num);

$return = gmp_pow($num, $exponent);

var_dump($return);

?>
object(GMP)#2 (1) {
  ["num"]=>
  string(1) "8"
}

2 · num · int · exponent

<?

$num = 2;
$exponent = 3;

$return = gmp_pow($num, $exponent);

var_dump($return);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "8"
}

3 · num · string · exponent

<?

$num = "2";
$exponent = 3;

$return = gmp_pow($num, $exponent);

var_dump($return);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "8"
}

4 · num · 0 · exponent · 0

<?

$num = 0;
$exponent = 0;

$return = gmp_pow($num, $exponent);

var_dump($return);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "1"
}
HomeMenu