File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ # SGN
2+
3+ ## Syntax
4+ ``` basic
5+ SGN(expression)
6+ ```
7+
8+ ## Description
9+
10+ Returns the sign of a numeric expression as follows:
11+ * -1 if the number is negative
12+ * 0 if the number is zero
13+ * 1 if the number is positive
14+
15+ The returned value type is [ byte] ( types.md#Byte ) .
16+
17+ ## Examples
18+
19+ ``` basic
20+ REM Print sign of different numbers
21+ PRINT "Sign of -5 is "; SGN(-5) ' Prints -1
22+ PRINT "Sign of 0 is "; SGN(0) ' Prints 0
23+ PRINT "Sign of 3.14 is "; SGN(3.14) ' Prints 1
24+ ```
25+
26+ ## Remarks
27+
28+ * This function is 100% Sinclair BASIC Compatible
29+ * If the argument is an unsigned value, the result will always be either 0 or 1
30+ * Using SGN with string expressions will result in a compile-time error
31+
32+ ## See also
33+
34+ * [ ABS] ( abs.md )
You can’t perform that action at this time.
0 commit comments