Expanded Multiplication

See all articles from CATS v3 n4
Author(s): H. E. Weppler
Publication: CATS Newsletter
Pub Details: CATS v3 n4 (Volume 3, Issue 4)
Date: July 1985
Pages: 3

[address omitted]
June 7, 1985

Mark Fisher
President,CATS

Dear Mr. Fisher,

In the May Newsletter I was impressed by Schrack’s program “Precision Multiplication”.

I am attaching a revision which shortens that program, reduces the manual inputs to two and adds a decimal fraction capability.

I enjoy the Newsletter and hope to attend a meeting soon.

Keep up the good work.

Sincerely,
H.E.Weppler


EXPANDED MULTIPLICATION

The short program listed in Figure One will give the complete product of two whole numbers of any length. (Based on Schrack,May,1985)

The ability to handle decimal fractions can be added to the program by inserting the additional lines listed in Figure Two.

  10 REM EXPANDED MULTIPLICATION
********************************
15 INPUT "FIRST TERM ";A$
20 PRINT 'A$''"MULTIPLIED BY:"
''
25 INPUT "SECOND TERM ";B$
30 PRINT B$''"EQUALS:"''
75 DIM P$(LEN A$+LEN B$+1)
80 FOR I=LEN A$ TO 1 STEP -1
85 LET C=0
90 FOR J=LEN B$ TO 1 STEP -1
95 IF P$(I+J)=" " THEN LET P$(
I+J)="0"
100 LET Q=VAL A$(I)*VAL B$(J)+V
AL P$(I+J)+C
105 LET C=INT (Q/10)
110 LET P$(I+J)=STR$ (Q-10*C)
115 NEXT J
120 LET P$(I)=STR$ C
125 NEXT I
155 IF P$(1)="0" AND P$(2)<>" "
THEN LET P$=P$(2 TO ): GO TO 15
5
160 PRINT P$
165 STOP

FIGURE ONE

  40 FOR D=LEN A$ TO 1 STEP -1
45 IF A$(D)="." THEN LET A$=A$
( TO D-1)+A$(D+1 TO ): LET D=LEN
A$-D+1: GO TO 55
50 NEXT D
55 FOR E=LEN B$ TO 1 STEP -1
60 IF B$(E)="." THEN LET B$=B$
( TO E-1)+B$(E+1 TO ): LET E=LEN
B$-E+1: GO TO 75
65 NEXT E
135 LET I=I+1: IF I>(D+E) THEN
GO TO 155
140 IF P$(LEN P$-I)="0" THEN LE
T P$(LEN P$-I)=" ": GO TO 135
145 LET P$=P$( TO LEN P$-D-E-1)
+"."+P$(LEN P$-D-E TO )

FIGURE TWO

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.