gmp_div_q
Description
Syntax
gmp_div_q( GMP|int|string $num1, GMP|int|string $num2, int $rounding_mode = GMP_ROUND_ZERO ): GMP
Parameters
num1
The number being divided.
A GMP object, an int or a numeric string.
num2
The number that num1 is being divided by.
A GMP object, an int or a numeric string.
rounding_mode
The result rounding is defined by the rounding_mode:
Constant | Description |
---|---|
GMP_ROUND_ZERO | The result is truncated towards 0. |
GMP_ROUND_PLUSINF | The result is rounded towards +infinity. |
GMP_ROUND_MINUSINF | The result is rounded towards -infinity. |
Return
Returns a GMP object.
Examples
1 · num1 num2 · GMP
<? $num1 = 2; $num2 = 3; $num1 = gmp_init($num1); $num2 = gmp_init($num2); $return = gmp_div_q($num1, $num2); var_dump($return);
object(GMP)#3 (1) { ["num"]=> string(1) "0" }
2 · num1 num2 · int
<? $num1 = 2; $num2 = 3; $return = gmp_div_q($num1, $num2); var_dump($return);
object(GMP)#1 (1) { ["num"]=> string(1) "0" }
3 · num1 num2 · string
<? $num1 = "2"; $num2 = "3"; $return = gmp_div_q($num1, $num2); var_dump($return);
object(GMP)#1 (1) { ["num"]=> string(1) "0" }
4 · rounding_mode · GMP_ROUND_ZERO
<? $num1 = 2; $num2 = 3; $rounding_mode = GMP_ROUND_ZERO; $return = gmp_div_q($num1, $num2, $rounding_mode); var_dump($return);
object(GMP)#1 (1) { ["num"]=> string(1) "0" }
5 · rounding_mode · GMP_ROUND_PLUSINF
<? $num1 = 2; $num2 = 3; $rounding_mode = GMP_ROUND_PLUSINF; $return = gmp_div_q($num1, $num2, $rounding_mode); var_dump($return);
object(GMP)#1 (1) { ["num"]=> string(1) "1" }
6 · rounding_mode · GMP_ROUND_MINUSINF
<? $num1 = -2; $num2 = 3; $rounding_mode = GMP_ROUND_MINUSINF; $return = gmp_div_q($num1, $num2, $rounding_mode); var_dump($return);
object(GMP)#1 (1) { ["num"]=> string(2) "-1" }
Links
Related
GMP
- gmp_abs
- gmp_add
- gmp_and
- gmp_binomial
- gmp_clrbit
- gmp_cmp
- gmp_com
- gmp_div
- gmp_div_qr
- gmp_div_r
- gmp_divexact
- gmp_export
- gmp_fact
- gmp_gcd
- gmp_gcdext
- gmp_hamdist
- gmp_import
- gmp_init
- gmp_intval
- gmp_invert
- gmp_jacobi
- gmp_kronecker
- gmp_lcm
- gmp_legendre
- gmp_mod
- gmp_mul
- gmp_neg
- gmp_nextprime
- gmp_or
- gmp_perfect_power
- gmp_perfect_square
- gmp_popcount
- gmp_pow
- gmp_powm
- gmp_prob_prime
- gmp_random_bits
- gmp_random_range
- gmp_random_seed
- gmp_root
- gmp_rootrem
- gmp_scan0
- gmp_scan1
- gmp_setbit
- gmp_sign
- gmp_sqrt
- gmp_sqrtrem
- gmp_strval
- gmp_sub
- gmp_testbit
- gmp_xor