Letztes Update am Di, 09 Mai 2023 16:19:25 +0200 von Andreas Potthoff
- Token: 187 / $BB | Abkürzung: rN | ROM Exec: 57495 / $E097
- Typ: Funktion, numerisch | Funktion: Arithmetik
- Syntax: RND (<numeric<)
Aktion, Hinweise, Tipps, Tricks:
- In Bearbeitung!
$008B-$008F RND Function Seed Value
This location holds the five-byte floating point value returned by the RND function. It is initially set to a seed value copied from ROM (the five bytes are 128, 79, 199, 82, 88–$80, $4F, $C7, $52, $58).
When the function RND(X) is called, the numeric value of X does not affect the number returned, but its sign does. If X is equal to 0, RND generates a seed value from chip-level hardware timers. If X is a positive number, RND(X) will return the next number in an arithmetic sequence. This sequence continues for such a long time without repeating itself, and gives such an even distribution of numbers, that it can be considered random. If X is negative, the seed value is changed to a number that corresponds to a scrambled floating point representation of the number X itself.
Given a particular seed value, the same pseudorandom series of numbers will always be returned. This can be handy for debugging purposes, but not where you wish to have truly random numbers.
The traditional Commodore method of selecting a random seed is by using the expression RND(-TI), mostly because RND(0) didn’t function correctly on early PETs. While the RND(0) form doesn’t really work right on the 64 either (see location 57495 ($E097)), the expression RND(-RND(0)) may produce a more random seed value.
|Befehle||CLOSE, CLR, CMD, CONT, DATA, DEF, DIM, END, FOR, GET, GET#, GOSUB, GOTO, IF, INPUT, INPUT#, LET, LIST, LOAD, NEW, NEXT, ON, OPEN, POKE, PRINT, PRINT#, READ, REM, RESTORE, RETURN, RUN, SAVE, STOP, SYS, VERIFY, WAIT|
|Befehle Spezial (Bywords)||FN, GO, NOT, SPC(, TAB(, THEN, TO, STEP|
|Arithmetische und logische Operatoren||+, –, *, /, ^, >, =, <, AND, OR|
|Funktionen||ABS, ASC, ATN, CHR$, COS, EXP, FRE, INT, LEFT$, LEN, LOG, MID$, PEEK, POS, RIGHT$, RND, SGN, SIN, SQR, STR$, TAN, USR, VAL|
|Konstanten und Systemvariablen||Pi, ST, TI, TI$|