What is gmp_sign in PHP?
gmp_sign is a function in PHP which checks the sign of a GMP number.
Syntax
gmp_sign(GMP|int|string $num): int
Parameters
The function takes in one parameter num.
numcan be a numeric string or GMP object.
Return value
-
The function returns 1 if
numis positive. -
The function returns -1 if
numis negative. -
The function returns 0 if
numis 0.
Code
<?phpecho gmp_sign("550") . "\n";echo gmp_sign("-700") . "\n";echo gmp_sign("0") . "\n";?>
Output
1
-1
0