Sgn

From NSB App Studio
Revision as of 19:41, 8 July 2012 by Brendon (talk | contribs)
Jump to navigation Jump to search

SGN(number)

Description

SGN returns an integer indicating the sign of a number. The required parameter, number, is any valid numeric expression. If number is less than zero -1 is returned, if number is greater than zero 1 is returned, if number is equal to zero, 0 is returned.

Example

REM SGN Example
'SGN returns the sign of a number as -1 or 1
DIM Pos, Neg, Zero
Pos = SGN(44)
Neg = SGN(-17)
Zero = SGN(100 - 100)
PRINT "Positive:", Pos
PRINT "Negative:", Neg
PRINT "Zero:", Zero

Output

Positive:     1
Negative:     -1
Zero:  0

Related Items

ABS