Sgn: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 30: | Line 30: | ||
[[abs|ABS]] | [[abs|ABS]] | ||
[[Category:Language Reference]] | |||
[[Category:Math]] |
Revision as of 15:25, 7 August 2012
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