gmp_sign
Description
Syntax
gmp_sign( GMP|int|string $num ): int
Parameters
num
Either a GMP object, or a numeric string provided that it is possible to convert the latter to an int.
Return
Returns 1 if num is positive, -1 if num is negative, and 0 if num is zero.
Examples
1 · num · GMP · negative
<? $num = -10; $num = gmp_init($num); $return = gmp_sign($num); echo $return;
-1
2 · num · GMP · zero
<? $num = 0; $num = gmp_init($num); $return = gmp_sign($num); echo $return;
0
3 · num · GMP · positive
<? $num = 10; $num = gmp_init($num); $return = gmp_sign($num); echo $return;
1
4 · num · int · negative
<? $num = -10; $return = gmp_sign($num); echo $return;
-1
5 · num · int · zero
<? $num = 0; $return = gmp_sign($num); echo $return;
0
6 · num · int · positive
<? $num = 10; $return = gmp_sign($num); echo $return;
1
7 · num · string · negative
<? $num = "-10"; $return = gmp_sign($num); echo $return;
-1
8 · num · string · zero
<? $num = "0"; $return = gmp_sign($num); echo $return;
0
9 · num · string · positive
<? $num = "10"; $return = gmp_sign($num); echo $return;
1
Links
GMP
- gmp_abs
- gmp_add
- gmp_and
- gmp_binomial
- gmp_clrbit
- gmp_cmp
- gmp_com
- gmp_div
- gmp_div_q
- 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_sqrt
- gmp_sqrtrem
- gmp_strval
- gmp_sub
- gmp_testbit
- gmp_xor