home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 22
/
022.d81
/
t.random
< prev
next >
Wrap
Text File
|
2022-08-26
|
985b
|
70 lines
Commodore's Random Number Generator
It is interesting to note that the
C-64's random number generator
rnd(i), where i is some integer,
returns a pseudo-random number
between 0 and 1 each time it is
executed in a program. Each time
RND(1) is executed in a program it
returns a random number.
For instance the basic program:
10 FOR I = 1 TO 10
20 PRINT RND(1)
30 NEXT I
will print 10 random numbers between 0
and 1. To get ten random numbers
between 0 and 10, in the above program
use:
20 PRINT 10 * RND(1)
or to get ten random integers between
zero and 9,
20 PRINT INT(10*RND(1))
Also, the statements
100 R1 = RND(1)*RND(1)
200 R2 = RND(1)^2
are different, since in R1 the random
number generator is called twice and
is more like
R1 = X * Y where X and Y are
random numbers, while
R2 = X * X where X is a random
number.
Question: Is the C-64's random
number generator really 'random'?
----< continued in next article >----