RND
Returns a random number
Implemented by: ansimin, hptsb, decbasic, Altair, a2int, Applesoft, TI994, CBM, msatari, level2, colormc, Sinclair, Atom, BBC, GWBASIC, MSX, bwbasic, ABasiC, VBDOS, FreeBASIC, minibasicmm, EndBASIC
With variations: dartmouth1 (return value between 0 and 1; argument ignored), Atari (only 0 ⇐ x < 1), trs80 (range variations: 0 for 0 to 1, N for 1 to N), trscolor (from 0 to 1 or from 1 to N), bw32, QBasic (only between 0 and 1), Gambas, ugBASIC (integers, parameter sets upper bound)
Also written as:
Usage
Variations
bwBASIC admittedly ignores any eventually passed argument.
MSX BASIC allows three different behaviors for RND according to the argument:
- 1 or more: returns a different value returned for each call
- 0: returns the same value returned in the previous call
- -1 or less: for each different argument value, returns always the same value
In Apple INTEGER BASIC, which obviously would not return a number between 0 and 1, the argument passed to RND defines the highest value of the 0-started range which can be returned.