home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 130
/
130.d81
/
bigrith.bas
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
7KB
|
244 lines
100 rem "bigrith" a four-function calculator for big numbers
110 rem by curt stalder october, 1994
112 dv=peek(186):if dv<8 then dv=8
113 tx=peek(646)
115 poke 53281,11:gosub 60000
120 print chr$(142):poke 646,3:poke 53281,11
150 tt$( 1 )="
160 tt$( 2 )[178]"
170 tt$( 3 )="
180 tt$( 4 )[178]"(NULL)(NULL) (NULL)usr (NULL)usr (NULL)(NULL) (NULL)usr (NULL)usr (NULL)sqr
190 tt$( 5 )="[207][208] [170] [180][208] [180][206] [170] [170] [180][170]
200 tt$( 6 )[178]"(NULL)(NULL) sqrand (NULL)sqr (NULL)(NULL) sqrand + sgn+
210 tt$( 7 )="
220 tt$( 8 )[178]"
230 tt$( 9 )="
240 :
250 dc$( 1 )[178]"a four-function calculator for really
260 dc$( 2 )=" big numbers, positive or negative,
270 dc$( 3 )[178]"integer, decimal fraction, or mixed,
280 dc$( 4 )=" up to 62 digits each operand.
290 dc$( 5 )[178]"c. c. stalder orlando, fl oct 1994
300 :
320 print"[147]"
330 for n=1 to 3:print spc(20-len(tt$(1))/2)tt$(n):next:print
340 for n=4 to 6:print spc(20-len(tt$(4))/2)tt$(n):next:print
350 for n=7 to 9:print spc(20-len(tt$(7))/2)tt$(n):next:print
360 print:poke 646,7
370 for n=1 to 4:print spc(20-len(dc$(1))/2)dc$(n):next
380 print:print:poke 646,10
390 print spc(20-len(dc$(5))/2)dc$(5)
400 :
410 print:print:poke 646,1
420 poke 199,abs(f):print tab(13)p$"[145]":for n=1 to 300:next:f=not f
430 p$="press any key":get k$:if k$="" then420
440 a=10:dim a$(a)
450 poke 646,7:a$(0)="[147] [206][205][206][205][206][205][206][205][206][205] options [206][205][206][205][206][205][206][205][206][205]"
460 a$(1)="do arithmetic
470 a$(2)[178]"quit"
480 a$(3)[178]""
490 a$(4)[178]""
500 a$(5)[178]""
510 a$(6)[178]""
520 a$(7)[178]""
530 a$(8)[178]""
540 a$(9)[178]""
550 [129] n[178]1 [164] a:b[178]n:[139] a$(n)[178]"" [167] n[178]a
560 [130]
570 [129] n[178]0 [164] b[171]1:[153] [163]5)a$(n):[153]:[130]:k[178]1
580 [151]214,22:[153]:[153][163]5)"listuse cursor keys and then returnsys"
590 [151]214,1[170]2[172]k:[153]
600 [153][163]5)""a$(k)"on":[151]198,0
610 [161]k$:[139]k$[179][177]"on"[175]k$[179][177]""[175]k$[179][177][199](13)[167]610
620 [139] k$[179][177][199](13) [167]640
630 [145] k [137] 1300,3000,680,680,680,680,680,680,680
640 [153][163]5)a$(k)
650 [139]k$[178]""[167]k[178]k[170]1:[139]k[177]b[171]1 [167]k[178]1
660 [139]k$[178]"on"[167]k[178]k[171]1:[139]k[179]1[167]k[178]b[171]1
670 [137]590
680 [153]"loaderror. the 'on..goto' dest. is wrong."
690 :
1300 [153]"load"
1310 [153]"load"
1320 v$[178]"0001020304050607080910111213141516171819"
1330 w$[178]"0908070605040302010010090807060504030201"
1340 d0$[178]"error. cannot divide by zero. do again."
1350 er$[178]"invalid entry. do again."
1360 :
1370 k$[178]"":a$[178]"":[151] 646,1:[153]"enter operand a: ";
1380 f1[178]0:f2[178]0:f3[178]0
1390 [161] k$:[139] k$[178]"" [167]1390
1400 [141]2250:[151] 646,7:[153] k$;:[151] 646,1
1410 [139] k$[178]"-" [175] [195](a$)[177]0 [167] [153]:[153]:[153] er$:[153]:[137]1370
1420 [139] f1[177]1 [176] f2[177]1 [176] f3[177]1 [167] [153]:[153] er$:[153]:[137]1370
1430 [139] k$[179][177][199](13) [167] a$[178]a$[170]k$:[137]1390
1440 op$[178]a$:[139] [200](op$,1)[178]"-" [167] op$[178][202](op$,2)
1450 [141]2320:aw$[178]op$:ad[178]ld:sa[178]0:[139] f1[178]1 [167] sa[178]1
1460 b$[178]"":[153]"enter operand b: ";
1470 f1[178]0:f2[178]0:f3[178]0
1480 [161] k$:[139] k$[178]"" [167]1480
1490 [141]2250:[151] 646,7:[153] k$;:[151] 646,1
1500 [139] f1[177]1 [176] f2[177]1 [176] f3[177]1 [167] [153]:[153] er$:[153]:[137]1460
1510 [139] k$[179][177][199](13) [167] b$[178]b$[170]k$:[137]1480
1520 op$[178]b$:[139] [200](op$,1)[178]"-" [167] op$[178][202](op$,2)
1530 [141]2320:bw$[178]op$:bd[178]ld:sb[178]0:[139] f1[178]1 [167] sb[178]1
1540 md[178]ad:[139] bd[177]ad [167] md[178]bd
1550 :
1560 [153]:[153]"choose operation: (result will be in r$)":[153]
1570 [153] [166]5)"a add b to a"
1580 [153] [166]5)"s subtract b from a"
1590 [153] [166]5)"m multiply a by b"
1600 [153] [166]5)"d divide a by b"
1610 [153] [166]5)"q quit (abort to main menu)"
1615 [153]
1620 [161] k$:[139] k$[178]"" [167]1620
1630 [139] k$[178]"q" [167] [137] 450
1640 [145] [171](k$[178]"a")[171]2[172](k$[178]"s")[171]3[172](k$[178]"m")[171]4[172](k$[178]"d") [137]1680,1780,1870,2050
1650 [153]"load"er$:[153]:[137]1560
1660 :
1670 :
1680 :[143] ** add section **
1690 xx[178]ti
1700 [141]2380:[141]2460:[141]2540:[141]2770
1710 [139] sl[178]1 [167] op$[178]r$:[141]2600:r$[178]op$
1720 [141]2670
1730 [139] ad[177]0 [176] bd[177]0 [167] r$[178][200](r$,[195](r$)[171]md)[170]"."[170][202](r$,[195](r$)[171]md[170]1)
1740 [141]2720
1750 [139] sl[178]1 [167] r$[178]"-"[170]r$
1760 ww$[178]"plus":[137]2860
1770 :
1780 :[143] ** subtract section **
1790 xx[178]ti
1800 [141]2380:[141]2460:[141]2540:op$[178]bw$:[141]2600:bw$[178]op$
1810 [141]2770
1820 [139]mg[178]0[175]sl[178]1[176]mg[178]1[175]sl[178]0[167] op$[178]r$:[141]2600:r$[178]op$:[141]2670:r$[178]"-"[170]r$
1830 [141]2670
1840 [139] ad[177]0 [176] bd[177]0 [167] r$[178][200](r$,[195](r$)[171]md)[170]"."[170][202](r$,[195](r$)[171]md[170]1)
1850 ww$[178]"minus":[137]2860
1860 :
1870 :[143] ** multiply section **
1880 xx[178]ti
1890 aw$[178]"0"[170]aw$
1900 mc$[178]aw$:mp$[178]bw$:aw$[178]"":bw$[178]mc$:mr$[178]""
1910 [139] [195](aw$)[179][195](mc$)[167] aw$[178]"0"[170]aw$:[137]1910
1920 [129] m[178][195](mp$) [164] 1 [169] [171]1
1930 [139] [202](mp$,m,1)[178]"0" [167]1980
1940 [129] l[178]1 [164] [197]([202](mp$,m,1))
1950 [141]2770:aw$[178]r$
1960 [151] 211,0:[153] r$;
1970 [130]
1980 mr$[178][201](r$,1)[170]mr$:aw$[178]"0"[170][200](r$,[195](r$)[171]1)
1990 [130]
2000 r$[178]r$[170][202](mr$,2):[141]2670
2010 [139] md[177]0 [167] r$[178][200](r$,[195](r$)[171]ad[171]bd)[170]"."[170][201](r$,ad[170]bd)
2020 [139] sa[179][177]sb [167] r$[178]"-"[170]r$
2030 ww$[178]"multiplied by":[141]2720:[137]2860
2040 :
2050 :[143] ** divide section **
2060 [139] b$[178]"0" [167] [153]""d0$"":[137]1320
2070 dd[178]1:[133]"minimum precision? (default: 1)";dd
2080 xx[178]ti
2085 dd[178]dd[170]1
2090 qw[178]0:q$[178]""
2100 aw$[178]"0"[170]aw$:op$[178]"0"[170]bw$:[141]2600:bw$[178]op$:bl[178][195](bw$):al[178][195](aw$)
2110 [129] l[178]1 [164] dd[170]md:aw$[178]aw$[170]"0":[130]
2120 ax$[178]aw$:aw$[178][200](ax$,bl):ax$[178][202](ax$,bl[170]1)
2130 [151] 211,0:[153] r$;:rw$[178]r$:[141]2770:[139] [200](t2$,1)[178]"0" [167]2150
2140 qw[178]qw[170]1:aw$[178]r$:[137]2130
2150 aw$[178][202](aw$,2)[170][200](ax$,1):ax$[178][202](ax$,2)
2160 q$[178]q$[170][202]([196](qw),2)
2170 [153] [201](q$,1);
2180 [139] [195](ax$)[177]0 [167] r$[178]rw$:qw[178]0:[137]2130
2190 dp[178]dd[170]md[170]ad[171]bd[171]1
2200 [139] [195](q$)[179]dp [167] q$[178]"0"[170]q$:[137]2200
2210 r$[178][200](q$,[195](q$)[171]dp)[170]"."[170][201](q$,dp):[141]2670:[141]2720
2220 [139] sa[179][177]sb [167] r$[178]"-"[170]r$
2230 ww$[178]"divided by":[137]2860
2240 [144]
2250 [143] s.r. to test validity of k$
2260 [139] k$[178]"-" [167] f1[178]f1[170]1:[137]2300
2270 [139] k$[178]"." [167] f2[178]f2[170]1:[137]2300
2280 [139] k$[178][199](13) [167]2300
2290 [139] k$[179]"0" [176] k$[177]"9" [167] f3[178]2
2300 [142]
2310 :
2320 [143] s.r. to locate and remove any decimal point from op$. put
2330 [143] its position in ld (number of digits to right of dec. point)
2340 ld[178]0:ol[178][195](op$):[129] n[178]1 [164] ol
2350 [139] [202](op$,n,1)[178]"." [167] ld[178]ol[171]n:op$[178][200](op$,n[171]1)[170][202](op$,n[170]1)
2360 [130]:[142]
2370 :
2380 [143] s.r. to standardize operands in aw$ and bw$ (pad to align
2390 [143] decimal points)
2400 ae[178]ad:be[178]bd:aw$[178]"0"[170]aw$:bw$[178]"0"[170]bw$
2410 [139] ae[179]bd [167] aw$[178]aw$[170]"0":ae[178]ae[170]1:[137]2410
2420 [139] be[179]ad [167] bw$[178]bw$[170]"0":be[178]be[170]1:[137]2420
2430 [139] [195](aw$)[179][195](bw$) [167] aw$[178]"0"[170]aw$:[137]2430
2440 [139] [195](bw$)[179][195](aw$) [167] bw$[178]"0"[170]bw$:[137]2440
2450 [142]
2460 :[143] determine which operand has the largest absolute value, and its sign
2470 mg[178]0:sl[178]0:j[178]1
2480 [139] [202](aw$,j,1)[178]"0"[175] [202](bw$,j,1)[178]"0"[167] j[178]j[170]1:[139] j[179][195](aw$)[167]2480
2490 [139] [202](aw$,j,1)[177][