[Coco] Is the RND command really generating a random number?
Johann Klasek
johann+coco at klasek.at
Fri May 19 11:43:16 EDT 2017
On Thu, May 18, 2017 at 09:05:25PM -0400, Glen Hewlett wrote:
[..]
> Remember to use A=RND(-TIMER) at the beginning of your program to generate a different random seed each time the computer is turned on.
Nice reading:
http://archive.worldofdragon.org/phpBB3/viewtopic.php?f=8&t=596
http://www.vavasour.ca/cfdm/issue27.htm#article20
Taken from the ECB's ROM code on a Dragon $9772 depending on the parameter
given
<0 ... seed with parameter
action: parameter * constant1 + constant2 -> RND storage, FAC
=0 ... next pseudorandom value
action: RND storage * constant1 + constant2-> RND storage, FAC
>0 ... next pseudorandom scaled from 1 to N
action: INT( INT(parameter) * ( RND storage * constant1 + constant2 -> RND storage ) + 1 ) -> FAC
Just to compare it to other MS BASIC implementations, especially CBM
BASIC: parameter >0 does no scaling, instead it mangles some hardware
dependend values (timer counter value, ...) into the result. This is not
good enough to get a stable and good distribution, only practical for
seeding the generator.
More information about the Coco
mailing list