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)
R U N
10 PRINT (RND(0) * 100)
R U N
10 PRINT ( R N D ( 0 ) * 1000)
R U N
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)
R U N
10 PRINT INT (RND(0)*1000)
R U N
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)
R U N
10 PRINT INT (RND(0)*12)
R U N
10 PRINT INT (RND(0)*25)
RUN
51
Summary of Contents for 65XE
Page 1: ...ATARI 65XE PERSONAL COMPUTER OWNER S MANUAL TM...
Page 3: ...ATARI 65XE PERSONAL COMPUTER TM...
Page 6: ...Part 1 GettingStarted 1...
Page 9: ...4...
Page 23: ...18...
Page 25: ...20...
Page 32: ...Part 2 Programming withATARI BASIC 27...
Page 33: ...28...
Page 59: ...54...
Page 69: ...64...
Page 82: ...Part3 Appendices 77...
Page 83: ...78...
Page 97: ...92...
Page 105: ...100...
Page 125: ...120...
Page 126: ...121 Index...
Page 127: ...122...
Page 134: ...ATARI 1987 Atari Corp All Rights Reserved Printed in Taiwan C072018 001 REV B K l 2 1987...
Page 135: ......