EasyManua.ls Logo

Radio Shack TRS-80 Model III - Page 192

Radio Shack TRS-80 Model III
274 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
TRS-80 MODEL III
10 RANDC
I|v|
20
PRINT
'
RND
30 fctO 1 (J 20
RANDOM
RANDOM is actually
a
complete statement rather than
a
function.
It
reseeds the
random number generator. If
a
program
uses
the RND function,
you may want to put
RANDOM at the beginning of the program. This
will
ensure
that you get an
unpredictable sequence
of
pseudo-random numbers each time
you
turn on the
Computer, load the program, and run it.
'DO LINE .1.0
JUST ONCF
KND(x)
Generates
a
pseudo-random
number using the
current pseudo-random
"seed
number'
'
(generated internally
and not
accessible to user)
.
rnd
may be used to
produce random numbers
between and
1
, or random integers
greater than
0,
depending
on the
argument.
RND(O) returns
a
single-precision
value between and
1 . RND(integer) returns
an
integer between
1 and integer inclusive
(integer must be
positive and less
than
32768). For example
,
rnd(55)
returns
a
pseudo-random
integer greater
than zero
and less than
56. RND(55.5)
returns
a
number in the same
range, because
RND uses
the INTeger
value of the
argument.
100 X
=
RND(2)
:
ON
X GOTO
200,300
SGN(x)
The
"sign"
function
: returns
-
1
for
X negative, for
X zero, and
+
1
for
X
positive.
100
ON
SGN(X) +
2
GOTO
200,300,400
182

Other manuals for Radio Shack TRS-80 Model III

Related product manuals