CakeFest 2024: The Official CakePHP Conference

gmp_divexact

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

gmp_divexact正確な除算

説明

gmp_divexact(GMP|int|string $num1, GMP|int|string $num2): GMP

高速な "exact division" アルゴリズムを使用して num1num2 で割ります。 この関数は、num1num2 で割り切れることがわかっている場合にのみ正確な結果を出力します。

パラメータ

num1

割られる数。

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

num2

num1 を割る数。

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

戻り値

GMP オブジェクトを返します。

例1 gmp_divexact() の例

<?php
$div1
= gmp_divexact("10", "2");
echo
gmp_strval($div1) . "\n";

$div2 = gmp_divexact("10", "3"); // 間違った結果となります
echo gmp_strval($div2) . "\n";
?>

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

5
2863311534

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top