PHP 8.3.4 Released!

gmp_pow

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)

gmp_powべき乗を計算する

説明

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

numexponent 乗を計算します。

パラメータ

num

もととなる数。

GMP オブジェクト、整数、あるいは数値に変換可能な数値形式の文字列。

exponent

正の数で、num を何乗するかを指定します。

戻り値

べき乗の結果を GMP 数で返します。 0^0 は 1 となります。

例1 gmp_pow() の例

<?php
$pow1
= gmp_pow("2", 31);
echo
gmp_strval($pow1) . "\n";
$pow2 = gmp_pow("0", 0);
echo
gmp_strval($pow2) . "\n";
$pow3 = gmp_pow("2", -1); // 負のべき乗を指定したため、警告を発生します
echo gmp_strval($pow3) . "\n";
?>

上の例の出力は以下となります。

2147483648
1

add a note

User Contributed Notes 1 note

up
-12
rahulkadukar at yahoo dot com
12 years ago
A Sample code can be shown as

<?php
echo gmp_strval(gmp_pow(4,4)); //This would give the answer as 256
?>
To Top