home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1993 June / 1993-06.d64 / nbc (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  3KB  |  102 lines

  1. 10 rem copyright 1993 - compute publications intl ltd - all rights reserved
  2. 20 print"[147]":poke 53280,6:poke 53281,6
  3. 30 print"[158]":ms$="[206]umber [194]ase [195]onversions":gosub 960
  4. 40 print"[159]":ms$="by [194]ruce [205]. [194]owden":gosub960:print""
  5. 50 ms$="[195]opyright, 1993":gosub960:ms$="[195][207][205][208][213][212][197] [208]ublications [201]ntl [204]td":gosub960
  6. 60 ms$="[193]ll [210]ights [210]eserved":gosub 960:gosub980
  7. 70 print"[147]"
  8. 80 ms$="[194][193][211][197][195][207][206] will convert numbers from any":gosub960
  9. 90 ms$="number base less than or equal to 36":gosub960
  10. 100 ms$="to another base in the same range":gosub960
  11. 110 gosub 980:if s=0 then 230
  12. 120 print"[147][211]elect from one of these function keys:"
  13. 130 print"f1 ** [213]se the same starting base and          number as before"
  14. 140 print"f3 ** [213]se just the same starting base"
  15. 150 print"f5 ** [213]se the ending base as the new          base and the solution"
  16. 160 print"      as the new number"
  17. 170 print"f7 ** [203]eep the same starting and ending"
  18. 180 print"      bases":print"f2 ** [211]end results to printer"
  19. 190 print"f4 ** [197]verything fresh"
  20. 200 geta$:ifa$=""ora$<"[133]"ora$>"[138]"then200
  21. 210 xx=asc(a$)-132:onxxgoto370,300,860,440,890,220
  22. 220 run230
  23. 230 print"[147][208]lease enter the starting base here:"
  24. 240 print"";tab(12):inputs:ifs>=2then260
  25. 250 printtab(8);"";s;"is less than 2.":goto280
  26. 260 ifs<=36then290
  27. 270 printtab(8);"";s;"is greater than 36."
  28. 280 print"  [212]he base must be between 2 and 36!":gosub 980:goto230
  29. 290 s=int(s)
  30. 300 print"[147][208]lease enter the ending base here:"
  31. 310 print"";tab(12):inpute:ife>=2then330
  32. 320 printtab(8);"";e;"is less than 2.":goto350
  33. 330 ife<=36then360
  34. 340 printtab(8);"";e;"is greater than 36."
  35. 350 print"  [212]he base must be between 2 and 36!":gosub 980:goto300
  36. 360 e=int(e):goto440
  37. 370 print"[147][208]lease enter the ending base here:"
  38. 380 print"";tab(12):inpute:ife>=2then410
  39. 390 printtab(8);"";e;"is less than 2."
  40. 400 print"  [212]he base must be between 2 and 36!":gosub 980:goto370
  41. 410 ife<=36then430
  42. 420 printtab(8);"";e;"is greater than 36.":goto400
  43. 430 e=int(e):goto470
  44. 440 print"[147]"
  45. 450 print"[217]ou may now enter the number which is   being converted from base";s
  46. 460 print"to base";e;"below":print"";tab(12):inputn$
  47. 470 print"  [208]lease standby for computation...":x=1
  48. 480 ifmid$(n$,x,1)="."then690
  49. 490 x=x+1:ifx<>len(n$)+1then480
  50. 500 i$=n$:f$="0":v=0
  51. 510 ifs=ethen820
  52. 520 ifs<>10then560
  53. 530 ifi$<>""then550
  54. 540 i$="0"
  55. 550 t=val(i$):v=val("."+f$):goto700
  56. 560 t=0:forx=len(i$)to1step-1:d=asc(mid$(i$,x,1)):ifd<48ord>57then580
  57. 570 t=t+(d-48)*s^(len(i$)-x)
  58. 580 ifd<65ord>90thennext:goto600
  59. 590 t=t+(d-55)*s^(len(i$)-x):next
  60. 600 ift<1e10then620
  61. 610 print"[212]his number is too long to be evaluated":goto110
  62. 620 iff$="0"then670
  63. 630 v=0:forx=1tolen(f$):d=asc(mid$(f$,x,1)):ifd<48ord>57then650
  64. 640 v=v+(d-48)/s^x
  65. 650 ifd<65ord>90thennext:goto670
  66. 660 v=v+(d-55)/s^x:next
  67. 670 i$=str$(t):f$=str$(v):f$=mid$(f$,2,len(f$)-1):ife=10then820
  68. 680 goto700
  69. 690 i$=mid$(n$,1,x-1):f$=mid$(n$,x+1,len(n$)-x):goto510
  70. 700 i$="":f$=""
  71. 710 a=t/e:dp=int(e*(a-int(a))+.5):ifdp<0ordp>9then730
  72. 720 i$=chr$(dp+48)+i$:goto740
  73. 730 i$=chr$(dp+55)+i$
  74. 740 t=int(a):ift<>0then710
  75. 750 x=1:a=v*e
  76. 760 ifint(a)<0orint(a)>9then780
  77. 770 f$=f$+mid$(str$(int(a)),2,len(str$(int(a)))):goto790
  78. 780 f$=f$+chr$(int(a)+55)
  79. 790 v=a-int(a):ifv=0then820
  80. 800 x=x+1:ifx<151thena=v*e:goto760
  81. 810 f$=f$+"..."
  82. 820 print"[147][212]he base";s;"number ";n$;" is"
  83. 830 if e=10 and f$<>"0" then print" ";i$;f$;" [146]"
  84. 840 if e<>10 or f$="0" then print" ";i$;".";f$;" [146]"
  85. 850 print"when expressed in base";e:goto110
  86. 860 s=e:if e=10 and f$<>"0" then n$=i$+f$
  87. 870 if e<>10 or f$="0" then n$=i$+"."+f$
  88. 880 t=0:v=0:i$="":f$="":goto370
  89. 890 print"[147]       [208][210][201][206][212][207][213][212][160][207][198][160][212][200][197][160][210][197][211][213][204][212][211]          [146]"
  90. 900 print""
  91. 910 print"[194]e sure that the printer is switched on and is device #4":gosub 980
  92. 920 open3,4,7:print#3,"[212]he base";s;"number ";n$;" is"
  93. 930 if e=10 and f$<>"0" then print#3,i$;f$
  94. 940 if e<>10 or f$="0" then print#3,i$;".";f$
  95. 950 print#3,"when expressed in base";e:print#3,:close3:goto110
  96. 960 rem message centering routine
  97. 970 for mx=1 to 20-len(ms$)/2:printchr$(32);:next:printms$:return
  98. 980 print"[158]"
  99. 990 ms$="[208]ress [193]ny [203]ey [212]o [195]ontinue":gosub 960
  100. 1000 get a$:if a$="" then 1000
  101. 1010 print"":return
  102.