Prints
-1.
Prints
O.
Prints
1.
You can compare these operations
to
a deck of cards:
RND(-
Til
is
like shuf-
fling the deck.
RND(O)
is
like
cutting
the cards. and RND(-RND(O))
is
like giving
the cards both a shuffle and a eut.
To generate random numbers in non-repeating sequences
as
would
be
needed.
say.
in games of chance. use RND(-RND(O)) to store a random seed and
then fetch
as
many random numbers
as
needed
with
RND
(1)
references. where 1
can
be
1 or any other positive. non-zero number.
Examples of using the
RND
function to generate random numbers
on
the
PET
are given in Chapter
5.
SGN
SGN.
for sign of a number. can
be
used to determine if a number
is
positive.
negative. or
zero.
Format:
SGN(arg)
where:
arg
is
a numeric constant. variable. or
expression.
The
SGN
function returns:
+1
if the number
is
positive.
non-zero.
oif the
nu
mber
is
zero.
-1
if the number
is
negative.
Examples:
?SGN(-6)
?SGN(O)
?SGN(44)
IF
A>C
THEN
SA=SGN(X)
IF
SGN(M) >
=0
THEN
PRINT
"POSITIVE NUMBER"
SIN
SIN
returns the sine of the argument.
Format:
SIN(arg)
where:
arg
Examples:
A=SIN(AG)
?SIN
(45*1T/180)
154
is
a numeric constant. variable. or expression
representing an angle
in
radians.
Prints sine of 45 degrees.