Commodore PET User Manual page 229

Table of Contents

Advertisement

Oength of A$)+ Oength of B$)
~
16
Examples:
12
+
4
~16
2
+
3
~16
8
+
8
~16
The example program will multiply two input numbers with equallengths of
eight digits: 99999999 and 99999999. to give us a 16-digit product.
99999999-
x99999999-
+
9999999800000001-
8 digits
8 digits
16 digits
Input the multiplier and multiplicand as two positive numeric strings. A$
and B$:
le PR l NT ":' l te1lE1IE1' 1 ULTI PLE l NTEGER MUL TI PL l CAT l OHlIElIElIE" :PR l NT
213 INPUT A$,B$
RUN
1IE1IE1IEMULTIPLE INTEGER MULTIPLICATIONlIElIElIE
799999999
7?99999999
Step 2: Separate both input strings into two segments:high (H) for the
leftmost digits and low (L) for the rightmost digits. The dividing point. variable
F.
tells the PET where to divide A$ and B$ into segments. The value of
F
is set at
lines 1002 and 1006 (for explanation refer to "Multiple Integer Addition:' page
198).
113130 X=LEN(A$):Y=LEN(B$)
X=8
Y=8
1002 IF X>Y THEN F=X/2:GOTO 11308
10134 F='T'/2
F=8/2
F=4
113136 IF F>INT(F)THEN F=INT(F)+l
Once F is set. the program divides the numbers into high and low segments.
This routine was presented in the "Multiple Integer Addition" program (see page
199). Lines 1010 through 1060 divide the two strings into high and low seg-
ments.
11310 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 'T'(=F
THE~l
BH=0:BL=VAL<B$) : GOTO 1070
1050 BH=VAL(LEFT$(B$,Y-F»
1060 BL=VAL<RIGHT$<B$,F»
216

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents