Skip to content

Commit 443459c

Browse files
committed
docs: Add SGN.md page
This fixes #871
1 parent 19c3ce0 commit 443459c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/sgn.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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)

0 commit comments

Comments
 (0)