PICO-8 Wiki
Tag: Visual edit
(→‎See also: abs() seems like a good see-also.)
 
(3 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
|number|required|The number to determine the sign of.
 
|number|required|The number to determine the sign of.
 
}}
 
}}
  +
 
== Technical Note ==
 
<code>sgn(0)</code> will return 1, not 0 as might be common on other platforms.
   
 
== Examples ==
 
== Examples ==
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
sgn(100) -- return 1
+
sgn(100) -- returns 1
  +
sgn(0) -- returns 1 (not 0)
 
sgn(-14) -- returns -1
 
sgn(-14) -- returns -1
 
</syntaxhighlight>
 
</syntaxhighlight>
 
== Technical Note ==
 
<code>sgn(0)</code> will return 1
 
   
 
== See also ==
 
== See also ==
 
* [[Lua]]
 
* [[Lua]]
 
* [[Math]]
 
* [[Math]]
  +
* [[Abs|<code>abs()</code>]]
 
[[Category:Reference]]
 
[[Category:Reference]]
 
[[Category:API]]
 
[[Category:API]]

Latest revision as of 00:22, 6 June 2018

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[]