EasyManua.ls Logo

Commodore PET - Page 219

Commodore PET
447 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Once
we
have determined the number of leading zeros in the answer,
we
separate the leading zeros from the remainder of the answer
C$.
At
line 1130, the
RIGHT$
function takes the LEN(C$)-L rightmost digits and stores them in the
answer variable
C$.
C$
=10101*1315171
_1_
MID$(C$.1,1)
1
12357
2 0
12357
3
00
2357
7
=0
=0
< > 0
LEN(C$)
= 7
L = 1
L=2
1=
LEN(C$)
1=7 drop out of loop
1130
C$=RIGHT$(C$,LEN(C$)-L)
C$=RIGHT$
(\0101112131517\.7-2)
C$=RIGHT$
001011121315171.5)
C$-11121315171
Step 7: Print the answer string C$. But before
we
print
C$,
we
check to
see
if the answer
is
to
be
negative by testing variable S at line 1140. If
S=
1,
that
means that originally
A$
<
B$,
and the final answer
is
to
be
negative,
so
a nega-
tive sign
is
added to
C$.
If S=O, the answer
is
positive,
so
nothing
is
added. Line
1150 prints C$:
1140
IF
:::;=1
THEN
(:$="_"
+(:$
J.15€1 F'F.:HJT:
F'F.:INT"A;·jS~·JEF:=".;
(:$:
F'RINT
The
la
st lines, 1160 through 1180, clear ail strings and variables to
zero,
or
to null mode and return the program to the beginning for the next input numbers.
The total program listing, complete
with
a
RUN,
is
listed below.
206

Table of Contents

Related product manuals