Commodore 16 User Manual page 30

Hide thumbs Also See for Commodore 16:
Table of Contents

Advertisement

10 PRINT "2001/2010=";
2001/2010
RUN
2001/20 W = 995522388
1984
fr
don't forget the semicolon
this space
G
left for the answers
sign
the answer for line 20 stays the
same
If you want to both PRINT the problem AND solve it you have to type it
I
twice: once in quotes and once out of quotes, as line 10 snows.
Order of Calculation
For a number less than one with several decimal places, the second
number would be a — instead of a +, indicating that the decimal point
is moved to the right.
For example:
.0003359 = 3.359E — 4
Other examples.
20 = 2E + 1
the decimal point is moved 1 digit left
105000 = 1.05E + 5 the decimal point is moved 5 digits left
.0666 = 6.66E — 2
the decimal point is moved 2 digits right
PERFORMING CALCULATIONS
You can perform more than one calculation In one line. Try typing this:
To perform a calculation, type PRINT and then the math problem
without quotes, as in the following:
10 PRINT 1+2, 2-1
20 PRINT 2'2, 4/2
RUN
3
1
4
2
For the first lime. PRINT dic) t print exactly what you typed in the
statement. Instead, your computer solved the calculations and PRINTed
only the answers. All you have to do to use PRINT to calculate is omit
the quotation marks. Now try this:
NEW
10 PRINT "2001/2010"
20 PRINT 2001 — 17
RUN
2001/2010
1984
one space is left here for the
answers sign
Since line 10 is in quotes. your computer just PRINTs the problem as if
It were regular text: exactly as it appears between the quotation marks.
Notice that no space is left for the numbers sign from line 10. as a is in
the printout for line 20. Now move the cursor back to line 10 and
change the line to this:
PRINT 200'50+5
Is the answer what you expected? Try this:
PRINT 50+51'200
Your Commodore 16 always performs calculations in a certain order.
Problems are solved from left to right: within that general rule, some
types of calculations are solved first The order that your computer
evaluates expressions is called the order of precedence.
FIRST:
Your computer checks for negative numbers (not subtrac-
tion. just negative numbers).
SECOND: Your computer solves any exponents.
THIRD:
Your computer solves all multiplication and division, from left
to right.
FOURTH. Your computer solves addition and subtraction• from left to
right.
NOTE: Your Commodore 16 always solves any pad of the problem
that's surrounded by parentheses first You can even put
parentheses within parentheses: 36 • (12 + (A / 3)). The contents of
me innermost parentheses are solved first
Sometimes its a good idea to out negative numbers in parentheses for
clarity. For example, if you want to multiply 45 by -5. type it like this:
45*(-5) Your computer can understand it with or without parentheses.
56
57

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Commodore 16 and is the answer not in the manual?

Questions and answers

Table of Contents