Di, 05 Sep 2023 02:55:40 +0200

C64 BASIC V2.0: Funktion: RND


Letztes Update am Di, 09 Mai 2023 16:19:25 +0200 von Andreas Potthoff


RND

  • 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.


Beispiele:

In Bearbeitung!


BefehleCLOSE, 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
FunktionenABS, ASC, ATN, CHR$, COS, EXP, FRE, INT, LEFT$, LEN, LOG, MID$, PEEK, POS, RIGHT$, RND, SGN, SIN, SQR, STR$, TAN, USR, VAL
Konstanten und SystemvariablenPi, ST, TI, TI$
image_pdfimage_print

Letztes Update am Di, 09 Mai 2023 16:19:25 +0200 von Andreas Potthoff


RND

  • 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.


Beispiele:

In Bearbeitung!


BefehleCLOSE, 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
FunktionenABS, ASC, ATN, CHR$, COS, EXP, FRE, INT, LEFT$, LEN, LOG, MID$, PEEK, POS, RIGHT$, RND, SGN, SIN, SQR, STR$, TAN, USR, VAL
Konstanten und SystemvariablenPi, ST, TI, TI$
image_pdfimage_print
Andreas Potthoffhttps://electrodrome.net
Computer-Nerd seit der ersten 8-bit Generation (1981), SysOp, IT-Spezialist, System Administrator, Webmaster... Wenn Sie mich unterstützen möchten, um dieses Projekt am Leben zu erhalten, verwenden Sie bitte die Amazon Affiliate-Links, den Paypal-Spenden-Link oder die Amazon Wunschliste. Vielen Dank für den Community Support!
- Werbung -

Kommentieren Sie den Artikel

Bitte geben Sie Ihren Kommentar ein!
Bitte geben Sie hier Ihren Namen ein

- Werbung -

Neue Artikel

Weitere Artikel