8-Bit Software Online Conversion

:2.$.Maxiply - Listing

10REM" * M A X I P L Y * Multiply Very Large Numbers. J.Davis '94. 20MODE7 30*FX202,32 40ONERRORGOTO3260 50DIMA$(750):DIMB$(750):DIMT$(751) 60MAX%=3000:FC%=0:VDU15 70LA%=0:LB%=0:KA%=0:KB%=0 80DA%=0:DB%=0:ZA%=0:ZB%=0 90IFP%<>1 P%=0 100*K.0"1234567890" 110*K.1"9999999999" 120CR$=" ":DG$=" Digits ":DI$=" Di gits " 130LI$=" Last input " 140TMD$=CHR$(10)+" TOO MANY DIGITS-P LEASE PAY ATTENTION!" 150MXP$=" * M A X I P L Y * " 160PRINTMXP$ 170PRINT" ENTER: 1-3000 digits (decima l opt.); R; ¶¶¶¶¶ R1-3000; R0; S(quare) ;I(nfo);Esc" 180VDU11:PRINT" STRINGVDU 1 190PRINT" FIRST NUMBER(max";MAX%;")?"; :INPUT" "IN$ 200FD%=0:FL%=0:REM dec/dec & ran 210IFLEFT$(IN$,1)<>"R" GOTO250 220 IFVAL(MID$(IN$,2,4))>MAX% OR LEN( IN$)>5 PRINTTMD$:GOTO190 230 R$=IN$:PROCrandom 240 GOTO330 250IFLEFT$(IN$,1)="I"CHAIN"MAXINFO" 260PROCcheck 270PROCarrayA 280GOTO320 290 PROCextendA 300 IFL%>MAX% PRINTLI$;L%;DI$:PRINTTM D$:GOTO290 310 PROCarrayA 320 IFL%=238 OR (L%=237 AND FF%=1) TH EN290:REM ext/dec 330IFFD%=0 DA%=LA% 340IFLEN(A$(KA%))<4THENA$(KA%)=A$(KA%) +"0":ZA%=ZA%+1:GOTO340 350IFMAX%=0 MAX%=1 360PRINT" SECOND NUMBER(max";MAX%;")?" ;:INPUT" "IN$ 370FD%=0:FL%=1:REM dec/dec & ran 380IFLEFT$(IN$,1)<>"R" GOTO420 390 IFVAL(MID$(IN$,2,4))>MAX% OR LEN( IN$)>5 PRINTTMD$:GOTO360 400 R$=IN$:PROCrandom 410 GOTO540 420IFLEFT$(IN$,1)<>"S" THEN460 430 IFLA%>MAX% PRINT" Max Square 15 00"DG$:PRINTTMD$:GOTO360 440 PROCsquare 450 GOTO560 460PROCcheck 470IFL%>MAX% PRINTLI$;L%;DI$:PRINTTMD$ :GOTO360 480PROCarrayB 490GOTO530 500 PROCextendB 510 IFL%>MAX% PRINTLI$;L%;DI$:PRINTTM D$:GOTO500 520 PROCarrayB 530 IFL%=238 OR (L%=237 AND FF%=1) TH EN500 540IFFD%=0 DB%=LB% 550IFLEN(B$(KB%))<4THENB$(KB%)=B$(KB%) +"0":ZB%=ZB%+1:GOTO550 560KC%=KA%+KB%:Z%=ZA%+ZB% 570TIME=0:GOTO1560 580" ** 590DEFPROCcheck 600PRINT" Checking..." 610IFFC%=1THEN630 620S$=LEFT$(IN$,1):IFVAL(S$)=0ANDS$<>" ."ANDLEN(IN$)>0 IN$=RIGHT$(IN$,LEN(IN$)- 1):GOTO620:REM lead 0,char 630A$="":B$="":C%=0:X%=1:FF%=0 640M$=MID$(IN$,X%,20):M%=LEN(M$) 650FORN%=1TOM% 660S$=MID$(M$,N%,1) 670IFS$<>"." OR FD%=1 THEN710 680 IFFL%=0 DA%=LA%+C%ELSEDB%=LB%+C% 690 FD%=1:FF%=1 700 GOTO740 710IFASC(S$)<48 OR ASC(S$)>57 THEN740 720A$=A$+S$ 730IFFD%=0 C%=C%+1 740NEXT 750B$=B$+A$ 760IFN%=21 THEN X%=X%+20:A$="":GOTO640 770IFFD%=0THEN790 780IFLEN(B$)-C%>0 AND RIGHT$(B$,1)="0" B$=LEFT$(B$,LEN(B$)-1):GOTO780 790IFB$="" AND FC%=0 VDU11:PRINTSPC(12 ):PRINT" ANSWER: 0 ":PRINT'" Try a more interesting number...":PRINT'" PR ESS SPACE":VDU9:G=GET:RUN 800IN$=B$:L%=LEN(IN$):LL%=L% 810VDU11 820ENDPROC 830" ** 840DEFPROCarrayA 850LA%=LA%+L%:MAX%=MAX%-L% 860PRINTCR$;LA%;DG$:PRINT 870IFFC%=1ANDIN$=""THEN920 880FORN%=1TOLL%STEP4 890KA%=KA%+1 900A$(KA%)=MID$(IN$,N%,4) 910NEXT 920FC%=0 930ENDPROC 940" ** 950DEFPROCextendA 960PRINT" FIRST NUMBER CONT.(max";MAX% ;")?";:INPUT" "IN$ 970FC%=1:REM lead 0 OK 980PROCcheck 990IFL%>MAX% THEN1020 1000PROCjoin(A$(KA%)) 1010A$(KA%)=JJ$ 1020ENDPROC 1030" ** 1040DEFPROCarrayB 1050LB%=LB%+L%:MAX%=MAX%-L% 1060PRINTCR$;LB%;DG$:PRINT 1070IFFC%=1ANDIN$=""THEN1120 1080FORN%=1TOLL%STEP4 1090KB%=KB%+1 1100B$(KB%)=MID$(IN$,N%,4) 1110NEXT 1120ENDPROC 1130" ** 1140DEFPROCextendB 1150PRINT" SECOND NUMBER CONT.(max";MAX %;")?";:INPUT" "IN$ 1160FC%=1:REM lead 0 OK 1170PROCcheck 1180IFL%>MAX% THEN1210 1190PROCjoin(B$(KB%)) 1200B$(KB%)=JJ$ 1210ENDPROC 1220" ** 1230DEFPROCjoin(J$) 1240G%=4-LEN(J$) 1250J$=J$+LEFT$(IN$,G%) 1260IN$=RIGHT$(IN$,LEN(IN$)-G%) 1270LL%=L%-G%:JJ$=J$ 1280ENDPROC 1290" ** 1300DEFPROCrandom 1310IFLEN(R$)=1 R%=RND(300):GOTO1340 1320R%=VAL(RIGHT$(R$,LEN(R$)-1)) 1330IFR%=0 R%=RND(1200) 1340PRINT" RANDOM - ";R%;DG$ 1350E%=(R%-1)DIV4 1360FORN%=0TOE% 1370S$=STR$(RND(9000)+999) 1380IFN%=E% S$=LEFT$(S$,(R%-1)MOD4+1) 1390IFFL%=0 A$(N%+1)=S$ELSEB$(N%+1)=S$ 1400PRINTS$; 1410NEXT 1420IFFL%=0 KA%=N%:LA%=R%ELSEKB%=N%:LB% =R% 1430MAX%=MAX%-R% 1440PRINT'CR$;R%;DG$:PRINT 1450ENDPROC 1460" ** 1470DEFPROCsquare 1480PRINT" SQUARE " 1490KB%=KA%:LB%=LA%:MAX%=MAX%-LA% 1500DB%=DA%:ZB%=ZA% 1510FORN%=1TOKA% 1520B$(N%)=A$(N%) 1530NEXT 1540PROCfirst 1550ENDPROC 1560FORN%=1TOKC% 1570T$(N%)="0000" 1580NEXT 1590REM" ** 1600IFKA%*KB%<100000 THEN1650 1610 NM$=STR$(INT(LA%*LB%/800)) 1620 PRINT" Really? Well, OK.":PRIN T'" This will take about an hour..." 1630 PRINT'" (With a pencil and a ve ry large piece of paper, about " LEFT$(NM$,1)","RIGHT$(NM$,3)" hours.)":P RINT 1640REM" Main Routine: 1650FL%=0:VDU9; 1660FORY%=1TOKB% 1670FORX%=1TOKA% 1680KZ%=X%+Y%-1 1690M=VAL(A$(X%))*VAL(B$(Y%)) 1700T$=STR$(VAL(T$(KZ%)+T$(KZ%+1))+M) 1710IFLEN(T$)<8 T$="0"+T$:GOTO1710 1720IFLEN(T$)=9 PROCcarryA 1730Q%=1 1740IFLEN(T$(KZ%-Q%))=5 PROCcarryB:GOTO 1740 1750T$(KZ%)=LEFT$(T$,4) 1760T$(KZ%+1)=RIGHT$(T$,4) 1770NEXTX% 1780VDU8:PRINT" ";Y%"/";KB%" | ";TIME/1 00"sec":VDU9; 1790IFKC%>=50 AND KB%>3 AND (KB%+1)DIV2 =Y% PRINT'" * HALF WAY * ":PRINT:VDU 9; 1800NEXTY% 1810REM" ** 1820LT%=LA%+LB% 1830DT%=DA%+DB%:DE%=LT%-DT%+Z%:REM dec 1840PROCzeroT 1850TM=TIME/100:MN=(TM)DIV60 1860IFTM>60 VDU7 1870PROCanswer:VDU14 1880G$=GET$ 1890IFG$="N" RUN 1900IFG$="D" PROCdisplay 1910IFG$="C" PROCcommas 1920IFG$="P" GOTO3080 1930GOTO1880 1940" ** 1950DEFPROCcarryA 1960T$(KZ%-1)=STR$(VAL(T$(KZ%-1))+1) 1970IFLEN(T$(KZ%-1))<4 T$(KZ%-1)="0"+T$ (KZ%-1):GOTO1970 1980T$=RIGHT$(T$,8) 1990ENDPROC 2000" ** 2010DEFPROCcarryB 2020T$(KZ%-Q%)=RIGHT$(T$(KZ%-Q%),4) 2030T$(KZ%-Q%-1)=STR$(VAL(T$(KZ%-Q%-1)) +1) 2040IFLEN(T$(KZ%-Q%-1))<4 T$(KZ%-Q%-1)= "0"+T$(KZ%-Q%-1):GOTO2040 2050Q%=Q%+1 2060ENDPROC 2070" ** 2080DEFPROCzeroT 2090C%=1:N%=0:REM lead 0 2100IFLEFT$(T$(C%),1)<>"0" OR N%=DT% TH EN2150 2110 N%=N%+1 2120 T$(C%)=RIGHT$(T$(C%),LEN(T$(C%))- 1) 2130 IFT$(C%)="" C%=C%+1 2140 GOTO2100 2150LT%=LT%-N%:DT%=DT%-N%:REM dec for p rint 2160C%=KC%:N%=0:REM trail 0 2170IFRIGHT$(T$(C%),1)<>"0" OR N%=DE% T HEN2220 2180 N%=N%+1 2190 T$(C%)=LEFT$(T$(C%),LEN(T$(C%))-1 ) 2200 IFT$(C%)="" C%=C%-1 2210 GOTO2170 2220LT%=LT%-N%+Z% 2230ENDPROC 2240" ** 2250DEFPROCanswer 2260PRINT'" ANSWER:" 2270IFDT%=0 PRINT"0"; 2280C%=0 2290FORN%=1TOKC% 2300IFT$(N%)="" THEN2360 2310FORM%=1TOLEN(T$(N%)) 2320IFC%=DT% PRINT"."; 2330PRINTMID$(T$(N%),M%,1); 2340C%=C%+1 2350NEXT 2360NEXT 2370PRINT'CR$;LT%;DG$ 2380PRINT'" Time=";MN;"min ";INT((TM- MN*60)*100)/100;"sec " 2390VDU3 2400PROCprompts 2410ENDPROC 2420" ** 2430DEFPROCdisplay 2440CLS:PRINTMXP$ 2450PRINT'" FIRST NUMBER:" 2460PROCfirst 2470PRINT" SECOND NUMBER:" 2480PROCsecond 2490PROCanswer 2500ENDPROC 2510" ** 2520DEFPROCfirst 2530C%=0:K%=4 2540IFDA%=0 PRINT"0"; 2550FORN%=1TOKA% 2560IFN%=KA% K%=K%-ZA% 2570FORM%=1TOK% 2580IFC%=DA% PRINT"."; 2590PRINTMID$(A$(N%),M%,1); 2600C%=C%+1 2610NEXT:NEXT 2620PRINT'CR$;LA%;DG$:PRINT 2630ENDPROC 2640" ** 2650DEFPROCsecond 2660C%=0:K%=4 2670IFDB%=0 PRINT"0"; 2680FORN%=1TOKB% 2690IFN%=KB% K%=K%-ZB% 2700FORM%=1TOK% 2710IFC%=DB% PRINT"."; 2720PRINTMID$(B$(N%),M%,1); 2730C%=C%+1 2740NEXT:NEXT 2750PRINT'CR$;LB%;DG$ 2760ENDPROC 2770" ** 2780DEFPROCcommas 2790CLS:PRINTMXP$ 2800PRINT'" ANSWER:" 2810C%=2-(DT%)MOD3:CK%=C%:D%=DT%+C%:CO% =0:CR%=131 2820GOSUB3000 2830IFDT%=0 PRINT"0. ";:CO%=CO%+3:CR%=1 29 2840FORN%=1TOKC% 2850IFT$(N%)=""THEN2950 2860FORM%=1TOLEN(T$(N%)) 2870C%=C%+1 2880PRINTMID$(T$(N%),M%,1); 2890GOSUB3000 2900IFC%MOD3<>2 OR C%-CK%=LT% THEN2940 2910 IFC%<>D% PRINT","; 2920 IFC%=D% PRINT". ";:CO%=CO%+1:CR%= 129 2930GOSUB3000 2940NEXT 2950NEXT 2960PRINT'CR$;LT%;DG$ 2970VDU3 2980PROCprompts 2990ENDPROC 3000IFCO%MOD39=0 PRINTCHR$(CR%); 3010CO%=CO%+1 3020RETURN 3030" ** 3040DEFPROCprompts 3050PRINT'" PRESS: N for new run."SPC(2 5)" D to display numbers and answer. (use SHIFT to scroll)"SPC(16)" C f or commas in answer."SPC(16)" P for prin t options.":PRINTSPC(8); 3060ENDPROC 3070REM" Print: 3080CLS:PRINTMXP$:PRINT'" PRINTER ON:"; 3090IFP%=0 PRINTTAB(20)" Parallel Print er:"ELSEPRINTTAB(17)" Serial Printer/120 0:" 3100PRINT'" PRESS: D to print numbers a nd answer. C to print answer wi th commas. R to return."SPC(27) " T to toggle parallel/serial.":PRINTSPC (8); 3110G$=GET$ 3120IFG$<>"D" AND G$<>"C" THEN3170 3130 VDU2:VDU15 3140 IFG$="D" PROCdisplay 3150 IFG$="C" PROCcommas 3160 VDU14:GOTO1880 3170IFG$="R" CLS:PRINTMXP$:PROCprompts: GOTO1880 3180IFG$<>"T" THEN3110 3190 IFP%=0 P%=1ELSEP%=0 3200 IFP%=1THEN*FX5,2 3210 IFP%=1THEN*FX8,4 3220 IFP%=0THEN*FX5,1 3230 *FX6,10 3240GOTO3080 3250REM" Escape: 3260VDU3:PRINT'" STRING 3270VDU11:PRINT" PRESS: E to Escape."SP C(27)" N for new run.":PRINTSPC(8); 3280G$=GET$:IFG$="E" PRINT'" STRING 39,"£");:VDU14:END 3290IFG$="N" RUN ELSE3280