abs

int sgn(num x)

num - any numeric type (int or fixed)

Description

Returns the sign of x as an integer.

1 – x is positive

0 – x is zero

-1 – x is negative

Examples

sgn(7) -> 1
sgn(-7) -> -1
sgn(12.3) -> 1
sgn(-12.3) -> -1
sgn(0) -> 0