Skip to content
Merged
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
25 changes: 25 additions & 0 deletions X16 Reference - 04 - BASIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ for GitHub's Markdown flavor. Do not remove!
| `LOG` | function | Returns the natural logarithm of a number | C64 |
| [`MENU`](#menu) | command | Invokes the Commander X16 utility menu | X16 |
| `MID$` | function | Returns a substring from the middle of a string | C64 |
| [`MOD`](#mod) | function | Returns the truncated remainder of a division | X16 |
| [`MON`](#mon) | command | Enters the machine language monitor | X16 |
| [`MOUSE`](#mouse) | command | Hides or shows mouse pointer | X16 |
| [`MOVSPR`](#movspr) | command | Set the X/Y position of a sprite | X16 |
Expand Down Expand Up @@ -950,6 +951,30 @@ The values are 1-based. If no column is given, only the line is changed.
MENU
```

### MOD

**TYPE: Function**
**FORMAT: MOD(<dividend>, <divisor>)**

**Action:** Returns the truncated remainder of <dividend> divided by <divisor>

The `MOD` function supports 16bit signed numbers (-32768 to 32767)

**EXAMPLE of MOD Function:**
```BASIC
PRINT MOD(-17, 5) :REM RESULT WILL HAVE THE SAME SIGN AS DIVIDEND
-2

PRINT MOD(17, 5)
2

PRINT MOD(42, 0) :REM DIVISOR IS 0, RETURN ERROR
?DIVISION BY ZERO ERROR

PRINT MOD(65000, 101) :REM DIVIDEND IS TOO LARGE FOR A SIGNED 16BIT VALUE
?ILLEGAL QUANTITY ERROR
```

### MON

**TYPE: Command**
Expand Down