EasyManua.ls Logo

Commodore PET - Page 212

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...
To obtain the high
(H)
and
low
(U
numeric
values for
both
A$
and B$. use
the
following
statements:
1000
X=LEN(A$):Y=LEN(B$)
1002
IF
X>Y
THEN
F=X/2:GOTO
1006
1004 F='r',··2
1006
IF
F>INT(F)
THEN
F=INT(F)+l
1008
F$=LEFT$(ZERO$,F)
1010
IF
X(=F
THEN
AH=0:AL=VAL(A$):GOTO
1040
1020
AH=VAL(LEFT$(A$,X-F»
1030
AL=VAL(RIGHT$<A$,F»
1040
IF
Y(=F
THEN
BL=VAL<B$):GOTO
1070
1050
BH=VAL<LEFT$<B$,Y-F»
1060
BL=VAL(RIGHT$<B$,F»
Statements
1010
and
1040
compare the string lengths
with
the
divider
point
F
(81.
If
the string is shorter than eight. AH (or
BH)
is
assigned a zero value. leaving
only
AL
(or
BU
equal
to
A$
or
B$.
If the string is longer than
eight
it
must
be
divided
into
high and
low
segments: AH or
BH
-
the
high segments - are
assigned the value of the
leftmost
LEN(X or y)
minus
eight
digits
at
1020
and
1050.
1020
AH=VAU:
LEFT$(A$,
>::-F)
)
AH=VAL(LEFT$(A$.16-S))
AH=VAL(LEFT$(
11121314151617IsI9101112131415161.S))
AH=vAL(!1121314151617/sll
AH-(1il1234567SI
To obtain AL.
the
rightmost
eight
digits
are extracted from
A$:
1030
AL=VAL<RIGHT$(A$,F»
AL=VAL(RIGHT$(111213j415i617js19IoI112131415161.s))
AL=
VAL
09101112131415161l
AL=111l901234561
The same procedure
is
used
to
extract
BH
and
BL.
Notice
that
the VAL
function converts the strings into numbers.
Step 3:
Once the large strings are divided
into
segments small enough
for
the
PET
to
handle. addition can begin.
Multiple
integer
addition
adds correspond-
ing groups
of
numbers by adding AH and
BH
together
and AL and BL together.
Whole
groups
of
digits
are added. instead
of
individual numbers.
When
a
number
is handled
as
a group
of
digits
and
not
as
a
numeric
string. the
addition
of each
number
does
not
have
to
be
do
ne
digit
by
digit
as
with
the numeric string
method.
The PET can add numbers, whereas
it
is
unable to
adct
numeric
strings.
AH
11il1234567S1
+BH Ililooooooool
CH
11il1234567S1
AL
11il901234561
+BL
11il579435721
CL
11il14S06702S1
199

Table of Contents

Related product manuals