PHP 8.3.4 Released!

gmp_div_qr

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

gmp_div_qr除算を行い、商と余りを得る

説明

gmp_div_qr(GMP|int|string $num1, GMP|int|string $num2, int $rounding_mode = GMP_ROUND_ZERO): array

この関数は、num1num2 で割ります。

パラメータ

num1

割られる数。

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

num2

num1 を割る数。

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

rounding_mode

引数 rounding_mode の説明については、 gmp_div_q() 関数を参照ください。

戻り値

配列を返します。配列の最初の要素は [n/d] (割算の結果の整数値)、2 番目の要素は (n - [n/d] * d) (割算の余り) です。

例1 GMP 数の割算

<?php
$a
= gmp_init("0x41682179fbf5");
$res = gmp_div_qr($a, "0xDEFE75");
printf("Result is: q - %s, r - %s",
gmp_strval($res[0]), gmp_strval($res[1]));
?>

参考

add a note

User Contributed Notes

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