mk90.basic.functions

Function RND

Return a bounded pseudorandom integer.

Syntax

RND(limit)

Returns

An integer from 0 to limit−1; limit must be 1–32767.

Behavior

The runtime starts from seed 1 for each program invocation. A nonzero 16-bit shift/XOR state is advanced and reduced modulo the positive limit. Re-running a program gives the same sequence.

This is not a real-valued RND function or a cryptographic generator. The range is bounded but no statistical uniformity guarantee is given.

Example

10 FOR I=1 TO 5
20 PRINT RND(6)+1
30 NEXT I
40 END

Limits and diagnostics

No RANDOMIZE or seed-setting statement. Nonpositive limits cause status 37.

Status-code reference.

See also

Expressions and precedence · Runtime