Sgn

From Pico-8 Wiki
Revision as of 01:22, 6 June 2018 by imported>Felice Enellen (→‎See also: abs() seems like a good see-also.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
sgn( [number] )
Returns the sign of a number, 1 for positive, -1 for negative
number
The number to determine the sign of.

Technical Note

sgn(0) will return 1, not 0 as might be common on other platforms.

Examples

sgn(100) -- returns 1
sgn(0)   -- returns 1 (not 0)
sgn(-14) -- returns -1

See also