OUTPUT: ---------------------------------------- START: MON MAR 7 10:40:40 PM THE VALUE OF PI TO 1001 DECIMAL PLACES: 3.14159265358979323846264338327950288419 7169399375105820974944592307816406286208 9986280348253421170679821480865132823066 4709384460955058223172535940812848111745 0284102701938521105559644622948954930381 9644288109756659334461284756482337867831 6527120190914564856692346034861045432664 8213393607260249141273724587006606315588 1748815209209628292540917153643678925903 6001133053054882046652138414695194151160 9433057270365759591953092186117381932611 7931051185480744623799627495673518857527 2489122793818301194912983367336244065664 3086021394946395224737190702179860943702 7705392171762931767523846748184676694051 3200056812714526356082778577134275778960 9173637178721468440901224953430146549585 3710507922796892589235420199561121290219 6086403441815981362977477130996051870721 1349999998372978049951059731732816096318 5950244594553469083026425223082533446850 3526193118817101000313783875288658753320 8381420617177669147303598253490428755468 7311595628638823537875937519577818577805 3217122680661300192787661119590921642019 898 END: WED MAR 9 4:27:30 PM ---------------------------------------- SOURCE: >LIST 5 CALL -936: VTAB 10: TAB 5: PRINT "HOW MANY DIGITS DO YOU WANT" ; 10 INPUT SIZE 15 CALL -936 16 DIM T$(25) 18 GOSUB 6000: PR#1: PRINT "START:" ;T$ 20 TEN=10: IF SIZE>200 THEN 50 30 TEN=100:SIZE=(SIZE+1)/2 50 POWER=4096:TERM=8192:RESULT= 12288 60 DIV=1000:ADD=2000:SUB=3000: INIT=4000:COPY=5000 70 DIM CONSTANT(2):CONSTANT(1) =25:CONSTANT(2)=239 100 REM MAIN LOOP 125 FOR PASS=1 TO 2 150 GOSUB INIT 200 GOSUB COPY 210 POINT=TERM:DIVIDE=EXP: GOSUB DIV 220 IF SIGN>0 THEN GOSUB ADD 230 IF SIGN<0 THEN GOSUB SUB 240 EXP=EXP+2:SIGN=-SIGN 250 POINT=POWER:DIVIDE=CONSTANT( PASS): GOSUB DIV 260 IF PASS=2 THEN GOSUB DIV 270 IF ZERO<>0 THEN 200 300 NEXT PASS 400 REM PRINT THE RESULT 500 PRINT 510 PRINT "THE VALUE OF PI TO " ;(TEN/100+1)*SIZE;" DECIMAL PLAC ES:": PRINT 515 NUMD=2 520 PRINT PEEK (RESULT);"."; 530 FOR PLACE=RESULT+1 TO RESULT+ SIZE 540 IF TEN=10 THEN 570 560 IF PEEK (PLACE)<10 THEN PRINT "0"; 570 PRINT PEEK (PLACE); 575 NUMD=NUMD+1 577 IF NUMD MOD 80=0 THEN PRINT 580 NEXT PLACE 590 PRINT 595 GOSUB 6000: PR#1: PRINT : PRINT "END:";T$ 596 PR#0 600 END 1000 REM DIVISION SUBROUTINE 1010 DIGIT=0:ZERO=0 1020 FOR PLACE=POINT TO POINT+SIZE 1030 DIGIT=DIGIT+ PEEK (PLACE) 1040 QUOTIENT=DIGIT/DIVIDE 1050 RESIDUE=DIGIT MOD DIVIDE 1055 ZERO=ZERO OR (QUOTIENT+RESIDUE) 1060 POKE PLACE,QUOTIENT 1070 DIGIT=TEN*RESIDUE 1080 NEXT PLACE 1090 RETURN 2000 REM ADDITION SUBROUTINE 2010 CARRY=0 2020 FOR PLACE=SIZE TO 0 STEP -1 2030 SUM= PEEK (RESULT+PLACE)+ PEEK (TERM+PLACE)+CARRY 2040 CARRY=0 2050 IF SUM<TEN THEN 2080 2060 SUM=SUM-TEN 2070 CARRY=1 2080 POKE RESULT+PLACE,SUM 2090 NEXT PLACE 2100 RETURN 3000 REM SUBTRACTION SUBROUTINE 3010 LOAN=0 3020 FOR PLACE=SIZE TO 0 STEP -1 3030 DIFFERENCE= PEEK (RESULT+PLACE) - PEEK (TERM+PLACE)-LOAN 3040 LOAN=0 3050 IF DIFFERENCE>=0 THEN 3080 3060 DIFFERENCE=DIFFERENCE+TEN 3070 LOAN=1 3080 POKE RESULT+PLACE,DIFFERENCE 3090 NEXT PLACE 3100 RETURN 4000 REM INITIALIZE REGISTERS 4010 FOR PLACE=0 TO SIZE 4020 POKE POWER+PLACE,0 4030 POKE TERM+PLACE,0 4040 IF PASS=1 THEN POKE RESULT+ PLACE,0 4050 NEXT PLACE 4060 POKE POWER,16/PASS ^ 2 4070 IF PASS=1 THEN DIVIDE=5 4080 IF PASS=2 THEN DIVIDE=239 4090 POINT=POWER: GOSUB DIV 4100 EXP=1:SIGN=3-2*PASS 4110 RETURN 5000 REM COPY "POWER" TO "TERM" 5010 FOR PLACE=0 TO SIZE 5020 POKE TERM+PLACE, PEEK (POWER+ PLACE) 5030 NEXT PLACE 5040 RETURN 6000 PR#7: IN#7 6010 INPUT ">",T$ 6020 PR#0: IN#0 6030 RETURN