returned to the traditional RND() function
This commit is contained in:
+6
-3
@@ -7,12 +7,11 @@ Luxferre's Truly Tiny BASIC (henceforth LTTB) is a lean dialect of the BASIC pro
|
||||
* 16-bit signed integers (from -32768 to 32767) as the only data type
|
||||
* String literals (only allowed in the `PRINT` statements, usually auto-uppercased)
|
||||
* 26 single-letter variables available (`A` to `Z`)
|
||||
* A special pseudo-variable `$` holding a random number from 0 to 9999
|
||||
* Line numbering from 1 to 32767
|
||||
* Unbounded subroutine call stack
|
||||
* Supported commands: `LET`, `IF ... (THEN)`, `INPUT`, `PRINT`, `GOTO`, `GOSUB`, `RETURN`, `END`, `LIST`, `CLEAR` (synonym `NEW`), `RUN`, `LOAD`, `SAVE`, `BYE`
|
||||
* Any invalid command is ignored, so it still is possible to use e.g. `REM` for comments
|
||||
* Allowed operations within expressions: `+`, `-`, `*`, `/`, parentheses `()`
|
||||
* Allowed operations within expressions: `+`, `-`, `*`, `/`, parentheses `()`, `RND(n)` function
|
||||
* Allowed relational operators with `IF` statements: `=`, `<>` (synonym `><`), `>`, `>=`, `<`, `<=`
|
||||
|
||||
## The interpreter
|
||||
@@ -31,6 +30,10 @@ Similarly to other Tiny BASIC implementations, LTTB does not support a dedicated
|
||||
|
||||
In case the evaluation result is outside the allowed range, it is automatically converted to this range (by taking it modulo 65536 and then subtracting 32768 if the modulo is over 32767) after every evaluation.
|
||||
|
||||
## `RND` function
|
||||
|
||||
The single function supported by LTB to use within expressions, `RND(n)` aka `$(n)`, takes the argument `n` and returns a (pseudo)random number from 0 to `n-1`. When `n` is negative, the behavior is undefined. It's recommended for the implementations to convert it to positive first by adding 32768.
|
||||
|
||||
## Statements
|
||||
|
||||
A **statement** in LTTB is a standalone execution unit. It usually corresponds to a single program line, with the exception of using it inside an `IF` statement (see below).
|
||||
@@ -51,7 +54,7 @@ The following commands are the core of LTTB.
|
||||
|
||||
Evaluates the expression `[expr]` and assigns the result to the variable `[var]`. `LET` is the only core command keyword that can be omitted in LTTB, because `[var]=` is enough to detect the assignment statement.
|
||||
|
||||
Examples: `let x=10`, `y = $ + 8`
|
||||
Examples: `let x=10`, `y = RND(10) + 8`
|
||||
|
||||
### `IF [expr1] [relop] [expr2] (THEN) [stmt]`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user