Returns the sign of an integer expression:
- -1 if the expression is negative
- 0 if the expression is zero
- 1 if the expression is positive
Examples
Produces -1.
Produces 0.
Produces 1.
REM Use SGN in a comparison
balance = -150
IF SGN(balance) = -1 THEN
PRINT "Account overdrawn!"
ENDIF
Notes
- Input must be an integer expression.
- Return value is always -1, 0, or 1.
- Can be used in compact conditionals or arithmetic to simplify sign handling.
See also: ABS · INT · ROUND