Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[v1.18.0](https://github.com/boriel-basic/zxbasic/tree/v1.18.1)
[v1.18.1](https://github.com/boriel-basic/zxbasic/tree/v1.18.1)
===
+ ! Fixes crash on simple cast from i32 to u32 and vice versa

Expand Down
4 changes: 2 additions & 2 deletions docs/overrides/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}

/* Responsive adjustments for smaller screens */
@media screen and (max-width: 768px) {
@media screen and (max-width: 1220px) {
[data-md-color-scheme="default"] .md-header {
height: 3.5rem;
}
Expand Down Expand Up @@ -107,7 +107,7 @@
}

.md-header__button {
margin: 0;
margin: 2px;
padding: 2px;
}

Expand Down
34 changes: 34 additions & 0 deletions docs/sgn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SGN

## Syntax
```basic
SGN(expression)
```

## Description

Returns the sign of a numeric expression as follows:
* -1 if the number is negative
* 0 if the number is zero
* 1 if the number is positive

The returned value type is [byte](types.md#Byte).

## Examples

```basic
REM Print sign of different numbers
PRINT "Sign of -5 is "; SGN(-5) ' Prints -1
PRINT "Sign of 0 is "; SGN(0) ' Prints 0
PRINT "Sign of 3.14 is "; SGN(3.14) ' Prints 1
```

## Remarks

* This function is 100% Sinclair BASIC Compatible
* If the argument is an unsigned value, the result will always be either 0 or 1
* Using SGN with string expressions will result in a compile-time error

## See also

* [ABS](abs.md)