Method 2: Multiple Integer Addition
Another
way
to overcome the
9-digit
length
limit
during addition
is
to use
the multiple integer addition method.
Multiple integer math reorganizes a large number into smaller seg-
ments.
Each
segment
is
handled independently during the addition. The in-
dividual answers are joined together into one final answer,
as
demonstrated
below:
Input numbers
I.,r--
.......
=~~~
.......
h
1
~
High answer
'--"""'("""---1
Low
The steps involved in multiple integer addition are
as
follows:
1.
Input the augend and addend
as
two
positive numeric strings.
2.
Divide the number into
two
equal parts of high, low.
3.
Calculate the sums of high-order digits and low-order digits.
4.
Concatenate the sums into one answer string.
5.
Print the answer string.
Step 1: Input the augend
and
addend
as
two
positive numbers
in
numeric string mode:
le
PR
I NT
Il
::lt!
••
MUL
TI
PLE
I NTEGER
ADD
I T I
Ot~:+::+i.
Il
: PI': I
tH
2(1
INPUT
A$,
B$
RUN
.:+i:+:MULTIPLE
INTEGER
ADDITION
•••
?1234567890123456
??57943572
A$
is
the augend and B$
is
the addend. The numbers are input
as
numeric strings
because:
1)
the numeric length
limit
is
avoided and
2)
it
allows use of string
functions to divide the numbers into small segments.
197