Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap1_198111 - decus/20-0020/artith.num
There are 2 other files named artith.num in the archive. Click here to see a list.
100'  NAME--ARITHMET
110'
120'  DESCRIPTION--ARITHMETIC WITH NUMBERS OF UP TO 300 DIGITS.
130'
140'  SOURCE--UNKNOWN
150'
160'  INSTRUCTIONS--
170'   1050 DATA: 1 (MULTIPLY), 0 (ADD), OR -1 (INTEGER DIVIDE).
180'   1060 DATA: FIRST NUMBER, IN 3-DIGIT GROUPS, SEPARATED BY COMMAS,
190'              FOLLOWED BY -1. SEE SAMPLE DATA IN 1060.
200'   1070 DATA: SECOND NUMBER IN THE SAME FORMAT FOR MULTIPLY OR ADD.
210'              AN ORDINARY NUMBER OF UP TO 6 DIGITS FOR DIVIDE.
220'
230'
240'  *  *  *  *  *  *   MAIN PROGRAM  *  *  *  *  *  *  *  *  *  *  *
250'
260 DIM A(100), B(100), C(200), X(100)
270 READ F9
280 REM  READ \ PRINT A,B
290 GOSUB 1080
300 GOSUB 1280
310 FOR I = 0 TO L
320 LET A(I) = C(I)
330 NEXT I
340 LET L1 = L
350 PRINT
360 IF F9 < 0 THEN 820
370 IF F9 > 0 THEN 400
380 PRINT "PLUS"
390 GOTO 410
400 PRINT "TIMES"
410 PRINT
420 GOSUB 1080
430 GOSUB 1280
440 FOR I = 0 TO L
450 LET B(I) = C(I)
460 NEXT I
470 LET L2 = L
480 PRINT
490 PRINT "EQUALS"
500 PRINT
510 IF F9 = 0 THEN 670
520 REM  C = A*B
530 LET L = L1+L2
540 FOR I = 0 TO L+1
550 LET C(I) = 0
560 NEXT I
570 FOR I = 0 TO L1
580 FOR J = 0 TO L2
590 LET K = I+J
600 LET C(K) = C(K) + A(I)*B(J)
610 NEXT J
620 NEXT I
630 REM  CARRY \ PRINT ANSWER
640 GOSUB 1180
650 GOSUB 1280
660 STOP
670 REM  C = A+B
680 IF L1 < L2 THEN 740
690 LET L = L1
700 FOR I = L2+1 TO L
710 LET B(I) = 0
720 NEXT I
730 GOTO 780
740 LET L = L2
750 FOR I = L1+1 TO L
760 LET A(I) = 0
770 NEXT I
780 FOR I = 0 TO L
790 LET C(I) = A(I)+B(I)
800 NEXT I
810 GOTO 630
820 PRINT "DIVIDED BY"
830 PRINT
840 READ B
850 PRINT B
860 PRINT
870 PRINT "EQUALS"
880 PRINT
890 REM  C() = A()/B
900 LET Y1 = 0
910 FOR I = L TO 0 STEP -1
920 LET A = A(I) + Y1*1000
930 LET X = INT(A/B)
940 LET Y1 = A - B*X
950 LET C(I) = X
960 NEXT I
970 IF L = 0 THEN 1010
980 IF C(L) > 0 THEN 1010
990 LET L = L-1
1000 GOTO 970
1010 GOSUB 1280
1020 PRINT
1030 PRINT "WITH REMAINDER = " Y1
1040 STOP
1050 DATA 1
1060 DATA 123,456,789,987,654,321,123,456,789,090,400,100,-1
1070 DATA 456,654,890,098,765,123,567,432,123,111,444,555,890,-1
1080 REM  READ C
1090 FOR I = 0 TO 100
1100 READ X(I)
1110 IF X(I) < 0 THEN 1130
1120 NEXT I
1130 LET L = I-1
1140 FOR I = 0 TO L
1150 LET C(I) = X(L-I)
1160 NEXT I
1170 RETURN
1180 REM  CARRY IN C
1190 FOR I = 0 TO L
1200 LET X = C(I)
1210 LET Y = INT(X/1000)
1220 LET C(I) = X - 1000*Y
1230 LET C(I+1) = C(I+1) + Y
1240 NEXT I
1250 IF Y = 0 THEN 1270
1260 LET L = L+1
1270 RETURN
1280 REM  PRINT C
1290 LET F8 = -1
1300 FOR I = L TO 0 STEP -1
1310 LET X = C(I)
1320 LET Q = 100
1330 FOR J = 1 TO 3
1340 LET Y = INT(X/Q)
1350 LET X = X - Q*Y
1360 LET Q = Q/10
1370 IF F8 = 0 THEN 1400
1380 IF Y = 0 THEN 1480
1390 LET F8 = 0
1400 PRINT Y;
1410 NEXT J
1420 IF F8 < 0 THEN 1450
1430 IF I = 0 THEN 1460
1440 PRINT ",   ";
1450 NEXT I
1460 PRINT
1470 RETURN
1480 PRINT "   ";
1490 GOTO 1410
1500 END