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
Содержание 65XE
Страница 1: ...ATARI 65XE PERSONAL COMPUTER OWNER S MANUAL TM...
Страница 3: ...ATARI 65XE PERSONAL COMPUTER TM...
Страница 6: ...Part 1 GettingStarted 1...
Страница 9: ...4...
Страница 23: ...18...
Страница 25: ...20...
Страница 32: ...Part 2 Programming withATARI BASIC 27...
Страница 33: ...28...
Страница 59: ...54...
Страница 69: ...64...
Страница 82: ...Part3 Appendices 77...
Страница 83: ...78...
Страница 97: ...92...
Страница 105: ...100...
Страница 125: ...120...
Страница 126: ...121 Index...
Страница 127: ...122...
Страница 134: ...ATARI 1987 Atari Corp All Rights Reserved Printed in Taiwan C072018 001 REV B K l 2 1987...
Страница 135: ......