Atari 65XE Owner's Manual page 56

Hide thumbs Also See for 65XE:
Table of Contents

Advertisement

The number in the parentheses is called a "dummy variable." It does
not matter what number is used as the dummy variable, but it is im-
portant that the parentheses appear and that they enclose something
(any number or letter). For typing ease, 0 is usually placed in the
dummy variable position. Change line 10 again as shown below:
10 PRINT (RND(0) * 10)
RUN
10 PRINT (RND(0) * 100)
R U N
10 PRINT (RND(0) * 1000)
RUN
Each program generates a different range of random numbers. PRINT
(RND(0) * 10) generates numbers up to 10 because the statement in-
structs the computer to multiply the random number by 10. Multiplying
by 10 moves the decimal point over one place. In PRINT (RND(0) *
100), multiplying by 100 moves the decimal point over two places, and
in PRINT (RND(0) * 1000), multiplying by 1000 moves the decimal
point over three places. If you want, you can multiply by much larger
numbers to generate large random numbers.
Because long numbers with many digits after the decimal point are
cumbersome, the computer has an instruction that tells it to print only
integers. Integers are whole numbers without any decimal points. The
instruction INT tells the computer to drop everything after the decimal
point. Reprogram the three variations of line 10 above and compare
the results:
10 PRINT INT (RND(0)*10)
R U N
10 PRINT INT (RND(0)*100)
RUN
10 PRINT INT (RND(0)*1000)
RUN
The programs generate numbers in the same ranges as before, but
the numbers are more readable without the digits after the decimal.
To generate numbers in a more specific range, try the examples
below:
10 PRINT INT (RND(0)*3)
RUN
10 PRINT INT (RND(0)*12)
RUN
10 PRINT INT (RND(0)*25)
RUN
51

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the 65XE and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents

Save PDF