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.


num can be a numeric string or GMP object.

Return value

  • The function returns 1 if num is positive.

  • The function returns -1 if num is negative.

  • The function returns 0 if num is 0.

Code

<?php
echo gmp_sign("550") . "\n";
echo gmp_sign("-700") . "\n";
echo gmp_sign("0") . "\n";
?>

Output


1
-1
0

Free Resources