PHP.nl

gmp_div_q

gmp_div_q

Divide numbers

GMP **gmp_div_q**  $num1  $num2 int $rounding_mode

Divides by and returns the integer result. num1``num2

num1The number being divided.

num2 The number that is being divided by. num1

rounding_mode The result rounding is defined by the , which can have the following values:

  `rounding_mode`- : The result is truncated           towards 0.          `GMP_ROUND_ZERO`
  • : The result is rounded towards . GMP_ROUND_PLUSINF``+infinity
  • : The result is rounded towards . GMP_ROUND_MINUSINF``-infinity

gmp.return

Voorbeeld: example

<?php
$div1 = gmp_div_q("100", "5");
echo gmp_strval($div1) . "\n";

$div2 = gmp_div_q("1", "3");
echo gmp_strval($div2) . "\n";

$div3 = gmp_div_q("1", "3", GMP_ROUND_PLUSINF);
echo gmp_strval($div3) . "\n";

$div4 = gmp_div_q("-1", "4", GMP_ROUND_PLUSINF);
echo gmp_strval($div4) . "\n";

$div5 = gmp_div_q("-1", "4", GMP_ROUND_MINUSINF);
echo gmp_strval($div5) . "\n";
?>
20
0
1
0
-1

Opmerking: > This function can also be called as . gmp_div

gmp_div_r``gmp_div_qr