Tandy 1000 Basic Reference Manual page 299

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter
10
I
BASIC
Keywords
RND
Function
RND[(nurnber)]
Returns a random number in the range 0 and 1.
BASIC uses the current seed when generating a random number
and produces the same sequence of random numbers each time
the program is run unless you reseed the random number gener-
ator. Use the RANDOMIZE statement to reseed the random
number generator
If
number
is negative, RND starts the sequence of random num-
bers at the beginning. If
number
is 0, RND repeats the last
number generated. If you omit
number or
specify a positive
value, RND returns the next number in the sequence.
Example
P R I N T RND(1
1
prints the next decimal fraction in the sequence.
Sample Program
1 0
F O R I
=
1 TO 5
20 P R I N T INT(RND*l00);
30 NEXT
I
This program produces 5 random integers. Line 20 converts the
decimal fraction returned by RND to a real number and trun-
cates the real number t o an integer.
297

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents