home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 130 / 130.d81 / bigrith.bas (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  7KB  |  244 lines

  1. 100 rem "bigrith"  a four-function calculator for big numbers
  2. 110 rem by curt stalder  october, 1994
  3. 112 dv=peek(186):if dv<8 then dv=8
  4. 113 tx=peek(646)
  5. 115 poke 53281,11:gosub 60000
  6. 120 print chr$(142):poke 646,3:poke 53281,11
  7. 150 tt$( 1 )="
  8. 160 tt$( 2 )[178]"
  9. 170 tt$( 3 )="
  10. 180 tt$( 4 )[178]"(NULL)(NULL) (NULL)usr (NULL)usr (NULL)(NULL) (NULL)usr (NULL)usr (NULL)sqr
  11. 190 tt$( 5 )="[207][208] [170]  [180][208] [180][206] [170]  [170]  [180][170]
  12. 200 tt$( 6 )[178]"(NULL)(NULL) sqrand (NULL)sqr (NULL)(NULL) sqrand +  sgn+
  13. 210 tt$( 7 )="
  14. 220 tt$( 8 )[178]"
  15. 230 tt$( 9 )="
  16. 240 :
  17. 250 dc$( 1 )[178]"a four-function calculator for really
  18. 260 dc$( 2 )="  big numbers, positive or negative,
  19. 270 dc$( 3 )[178]"integer, decimal fraction, or mixed,
  20. 280 dc$( 4 )="    up to 62 digits each operand.
  21. 290 dc$( 5 )[178]"c. c. stalder  orlando, fl  oct 1994
  22. 300 :
  23. 320 print"[147]"
  24. 330 for n=1 to 3:print spc(20-len(tt$(1))/2)tt$(n):next:print
  25. 340 for n=4 to 6:print spc(20-len(tt$(4))/2)tt$(n):next:print
  26. 350 for n=7 to 9:print spc(20-len(tt$(7))/2)tt$(n):next:print
  27. 360 print:poke 646,7
  28. 370 for n=1 to 4:print spc(20-len(dc$(1))/2)dc$(n):next
  29. 380 print:print:poke 646,10
  30. 390 print spc(20-len(dc$(5))/2)dc$(5)
  31. 400 :
  32. 410 print:print:poke 646,1
  33. 420 poke 199,abs(f):print tab(13)p$"[145]":for n=1 to 300:next:f=not f
  34. 430 p$="press any key":get k$:if k$="" then420
  35. 440 a=10:dim a$(a)
  36. 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]"
  37. 460 a$(1)="do arithmetic
  38. 470 a$(2)[178]"quit"
  39. 480 a$(3)[178]""
  40. 490 a$(4)[178]""
  41. 500 a$(5)[178]""
  42. 510 a$(6)[178]""
  43. 520 a$(7)[178]""
  44. 530 a$(8)[178]""
  45. 540 a$(9)[178]""
  46. 550 [129] n[178]1 [164] a:b[178]n:[139] a$(n)[178]"" [167] n[178]a
  47. 560 [130]
  48. 570 [129] n[178]0 [164] b[171]1:[153] [163]5)a$(n):[153]:[130]:k[178]1
  49. 580 [151]214,22:[153]:[153][163]5)"listuse cursor keys and then returnsys"
  50. 590 [151]214,1[170]2[172]k:[153]
  51. 600 [153][163]5)""a$(k)"on":[151]198,0
  52. 610 [161]k$:[139]k$[179][177]"on"[175]k$[179][177]""[175]k$[179][177][199](13)[167]610
  53. 620 [139] k$[179][177][199](13) [167]640
  54. 630 [145] k [137] 1300,3000,680,680,680,680,680,680,680
  55. 640 [153][163]5)a$(k)
  56. 650 [139]k$[178]""[167]k[178]k[170]1:[139]k[177]b[171]1 [167]k[178]1
  57. 660 [139]k$[178]"on"[167]k[178]k[171]1:[139]k[179]1[167]k[178]b[171]1
  58. 670 [137]590
  59. 680 [153]"loaderror.  the 'on..goto' dest. is wrong."
  60. 690 :
  61. 1300 [153]"load"
  62. 1310 [153]"load"
  63. 1320 v$[178]"0001020304050607080910111213141516171819"
  64. 1330 w$[178]"0908070605040302010010090807060504030201"
  65. 1340 d0$[178]"error. cannot divide by zero. do again."
  66. 1350 er$[178]"invalid entry.  do again."
  67. 1360 :
  68. 1370 k$[178]"":a$[178]"":[151] 646,1:[153]"enter operand a: ";
  69. 1380 f1[178]0:f2[178]0:f3[178]0
  70. 1390 [161] k$:[139] k$[178]"" [167]1390
  71. 1400 [141]2250:[151] 646,7:[153] k$;:[151] 646,1
  72. 1410 [139] k$[178]"-" [175] [195](a$)[177]0 [167] [153]:[153]:[153] er$:[153]:[137]1370
  73. 1420 [139] f1[177]1 [176] f2[177]1 [176] f3[177]1 [167] [153]:[153] er$:[153]:[137]1370
  74. 1430 [139] k$[179][177][199](13) [167] a$[178]a$[170]k$:[137]1390
  75. 1440 op$[178]a$:[139] [200](op$,1)[178]"-" [167] op$[178][202](op$,2)
  76. 1450 [141]2320:aw$[178]op$:ad[178]ld:sa[178]0:[139] f1[178]1 [167] sa[178]1
  77. 1460 b$[178]"":[153]"enter operand b: ";
  78. 1470 f1[178]0:f2[178]0:f3[178]0
  79. 1480 [161] k$:[139] k$[178]"" [167]1480
  80. 1490 [141]2250:[151] 646,7:[153] k$;:[151] 646,1
  81. 1500 [139] f1[177]1 [176] f2[177]1 [176] f3[177]1 [167] [153]:[153] er$:[153]:[137]1460
  82. 1510 [139] k$[179][177][199](13) [167] b$[178]b$[170]k$:[137]1480
  83. 1520 op$[178]b$:[139] [200](op$,1)[178]"-" [167] op$[178][202](op$,2)
  84. 1530 [141]2320:bw$[178]op$:bd[178]ld:sb[178]0:[139] f1[178]1 [167] sb[178]1
  85. 1540 md[178]ad:[139] bd[177]ad [167] md[178]bd
  86. 1550 :
  87. 1560 [153]:[153]"choose operation: (result will be in r$)":[153]
  88. 1570 [153] [166]5)"a  add b to a"
  89. 1580 [153] [166]5)"s  subtract b from a"
  90. 1590 [153] [166]5)"m  multiply a by b"
  91. 1600 [153] [166]5)"d  divide a by b"
  92. 1610 [153] [166]5)"q  quit (abort to main menu)"
  93. 1615 [153]
  94. 1620 [161] k$:[139] k$[178]"" [167]1620
  95. 1630 [139] k$[178]"q" [167] [137] 450
  96. 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
  97. 1650 [153]"load"er$:[153]:[137]1560
  98. 1660 :
  99. 1670 :
  100. 1680 :[143] ** add section **
  101. 1690 xx[178]ti
  102. 1700 [141]2380:[141]2460:[141]2540:[141]2770
  103. 1710 [139] sl[178]1 [167] op$[178]r$:[141]2600:r$[178]op$
  104. 1720 [141]2670
  105. 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)
  106. 1740 [141]2720
  107. 1750 [139] sl[178]1 [167] r$[178]"-"[170]r$
  108. 1760 ww$[178]"plus":[137]2860
  109. 1770 :
  110. 1780 :[143] ** subtract section **
  111. 1790 xx[178]ti
  112. 1800 [141]2380:[141]2460:[141]2540:op$[178]bw$:[141]2600:bw$[178]op$
  113. 1810 [141]2770
  114. 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$
  115. 1830 [141]2670
  116. 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)
  117. 1850 ww$[178]"minus":[137]2860
  118. 1860 :
  119. 1870 :[143] ** multiply section **
  120. 1880 xx[178]ti
  121. 1890 aw$[178]"0"[170]aw$
  122. 1900 mc$[178]aw$:mp$[178]bw$:aw$[178]"":bw$[178]mc$:mr$[178]""
  123. 1910 [139] [195](aw$)[179][195](mc$)[167] aw$[178]"0"[170]aw$:[137]1910
  124. 1920 [129] m[178][195](mp$) [164] 1 [169] [171]1
  125. 1930 [139] [202](mp$,m,1)[178]"0" [167]1980
  126. 1940 [129] l[178]1 [164] [197]([202](mp$,m,1))
  127. 1950 [141]2770:aw$[178]r$
  128. 1960 [151] 211,0:[153] r$;
  129. 1970 [130]
  130. 1980 mr$[178][201](r$,1)[170]mr$:aw$[178]"0"[170][200](r$,[195](r$)[171]1)
  131. 1990 [130]
  132. 2000 r$[178]r$[170][202](mr$,2):[141]2670
  133. 2010 [139] md[177]0 [167] r$[178][200](r$,[195](r$)[171]ad[171]bd)[170]"."[170][201](r$,ad[170]bd)
  134. 2020 [139] sa[179][177]sb [167] r$[178]"-"[170]r$
  135. 2030 ww$[178]"multiplied by":[141]2720:[137]2860
  136. 2040 :
  137. 2050 :[143] ** divide section **
  138. 2060 [139] b$[178]"0" [167] [153]""d0$"":[137]1320
  139. 2070 dd[178]1:[133]"minimum precision?  (default: 1)";dd
  140. 2080 xx[178]ti
  141. 2085 dd[178]dd[170]1
  142. 2090 qw[178]0:q$[178]""
  143. 2100 aw$[178]"0"[170]aw$:op$[178]"0"[170]bw$:[141]2600:bw$[178]op$:bl[178][195](bw$):al[178][195](aw$)
  144. 2110 [129] l[178]1 [164] dd[170]md:aw$[178]aw$[170]"0":[130]
  145. 2120 ax$[178]aw$:aw$[178][200](ax$,bl):ax$[178][202](ax$,bl[170]1)
  146. 2130 [151] 211,0:[153] r$;:rw$[178]r$:[141]2770:[139] [200](t2$,1)[178]"0" [167]2150
  147. 2140 qw[178]qw[170]1:aw$[178]r$:[137]2130
  148. 2150 aw$[178][202](aw$,2)[170][200](ax$,1):ax$[178][202](ax$,2)
  149. 2160 q$[178]q$[170][202]([196](qw),2)
  150. 2170 [153] [201](q$,1);
  151. 2180 [139] [195](ax$)[177]0 [167] r$[178]rw$:qw[178]0:[137]2130
  152. 2190 dp[178]dd[170]md[170]ad[171]bd[171]1
  153. 2200 [139] [195](q$)[179]dp [167] q$[178]"0"[170]q$:[137]2200
  154. 2210 r$[178][200](q$,[195](q$)[171]dp)[170]"."[170][201](q$,dp):[141]2670:[141]2720
  155. 2220 [139] sa[179][177]sb [167] r$[178]"-"[170]r$
  156. 2230 ww$[178]"divided by":[137]2860
  157. 2240 [144]
  158. 2250 [143] s.r. to test validity of k$
  159. 2260 [139] k$[178]"-" [167] f1[178]f1[170]1:[137]2300
  160. 2270 [139] k$[178]"." [167] f2[178]f2[170]1:[137]2300
  161. 2280 [139] k$[178][199](13) [167]2300
  162. 2290 [139] k$[179]"0" [176] k$[177]"9" [167] f3[178]2
  163. 2300 [142]
  164. 2310 :
  165. 2320 [143] s.r. to locate and remove any           decimal point from op$.  put
  166. 2330 [143] its position in ld (number of           digits to right of dec. point)
  167. 2340 ld[178]0:ol[178][195](op$):[129] n[178]1 [164] ol
  168. 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)
  169. 2360 [130]:[142]
  170. 2370 :
  171. 2380 [143]  s.r. to standardize operands            in aw$ and bw$ (pad to align
  172. 2390 [143]  decimal points)
  173. 2400 ae[178]ad:be[178]bd:aw$[178]"0"[170]aw$:bw$[178]"0"[170]bw$
  174. 2410 [139] ae[179]bd [167] aw$[178]aw$[170]"0":ae[178]ae[170]1:[137]2410
  175. 2420 [139] be[179]ad [167] bw$[178]bw$[170]"0":be[178]be[170]1:[137]2420
  176. 2430 [139] [195](aw$)[179][195](bw$) [167] aw$[178]"0"[170]aw$:[137]2430
  177. 2440 [139] [195](bw$)[179][195](aw$) [167] bw$[178]"0"[170]bw$:[137]2440
  178. 2450 [142]
  179. 2460 :[143] determine which operand has the largest absolute value, and its sign
  180. 2470 mg[178]0:sl[178]0:j[178]1
  181. 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
  182. 2490 [139] [202](aw$,j,1)[177][