home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1993 June
/
1993-06.d64
/
nbc
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
3KB
|
102 lines
10 rem copyright 1993 - compute publications intl ltd - all rights reserved
20 print"[147]":poke 53280,6:poke 53281,6
30 print"[158]":ms$="[206]umber [194]ase [195]onversions":gosub 960
40 print"[159]":ms$="by [194]ruce [205]. [194]owden":gosub960:print""
50 ms$="[195]opyright, 1993":gosub960:ms$="[195][207][205][208][213][212][197] [208]ublications [201]ntl [204]td":gosub960
60 ms$="[193]ll [210]ights [210]eserved":gosub 960:gosub980
70 print"[147]"
80 ms$="[194][193][211][197][195][207][206] will convert numbers from any":gosub960
90 ms$="number base less than or equal to 36":gosub960
100 ms$="to another base in the same range":gosub960
110 gosub 980:if s=0 then 230
120 print"[147][211]elect from one of these function keys:"
130 print"f1 ** [213]se the same starting base and number as before"
140 print"f3 ** [213]se just the same starting base"
150 print"f5 ** [213]se the ending base as the new base and the solution"
160 print" as the new number"
170 print"f7 ** [203]eep the same starting and ending"
180 print" bases":print"f2 ** [211]end results to printer"
190 print"f4 ** [197]verything fresh"
200 geta$:ifa$=""ora$<"[133]"ora$>"[138]"then200
210 xx=asc(a$)-132:onxxgoto370,300,860,440,890,220
220 run230
230 print"[147][208]lease enter the starting base here:"
240 print"";tab(12):inputs:ifs>=2then260
250 printtab(8);"";s;"is less than 2.":goto280
260 ifs<=36then290
270 printtab(8);"";s;"is greater than 36."
280 print" [212]he base must be between 2 and 36!":gosub 980:goto230
290 s=int(s)
300 print"[147][208]lease enter the ending base here:"
310 print"";tab(12):inpute:ife>=2then330
320 printtab(8);"";e;"is less than 2.":goto350
330 ife<=36then360
340 printtab(8);"";e;"is greater than 36."
350 print" [212]he base must be between 2 and 36!":gosub 980:goto300
360 e=int(e):goto440
370 print"[147][208]lease enter the ending base here:"
380 print"";tab(12):inpute:ife>=2then410
390 printtab(8);"";e;"is less than 2."
400 print" [212]he base must be between 2 and 36!":gosub 980:goto370
410 ife<=36then430
420 printtab(8);"";e;"is greater than 36.":goto400
430 e=int(e):goto470
440 print"[147]"
450 print"[217]ou may now enter the number which is being converted from base";s
460 print"to base";e;"below":print"";tab(12):inputn$
470 print" [208]lease standby for computation...":x=1
480 ifmid$(n$,x,1)="."then690
490 x=x+1:ifx<>len(n$)+1then480
500 i$=n$:f$="0":v=0
510 ifs=ethen820
520 ifs<>10then560
530 ifi$<>""then550
540 i$="0"
550 t=val(i$):v=val("."+f$):goto700
560 t=0:forx=len(i$)to1step-1:d=asc(mid$(i$,x,1)):ifd<48ord>57then580
570 t=t+(d-48)*s^(len(i$)-x)
580 ifd<65ord>90thennext:goto600
590 t=t+(d-55)*s^(len(i$)-x):next
600 ift<1e10then620
610 print"[212]his number is too long to be evaluated":goto110
620 iff$="0"then670
630 v=0:forx=1tolen(f$):d=asc(mid$(f$,x,1)):ifd<48ord>57then650
640 v=v+(d-48)/s^x
650 ifd<65ord>90thennext:goto670
660 v=v+(d-55)/s^x:next
670 i$=str$(t):f$=str$(v):f$=mid$(f$,2,len(f$)-1):ife=10then820
680 goto700
690 i$=mid$(n$,1,x-1):f$=mid$(n$,x+1,len(n$)-x):goto510
700 i$="":f$=""
710 a=t/e:dp=int(e*(a-int(a))+.5):ifdp<0ordp>9then730
720 i$=chr$(dp+48)+i$:goto740
730 i$=chr$(dp+55)+i$
740 t=int(a):ift<>0then710
750 x=1:a=v*e
760 ifint(a)<0orint(a)>9then780
770 f$=f$+mid$(str$(int(a)),2,len(str$(int(a)))):goto790
780 f$=f$+chr$(int(a)+55)
790 v=a-int(a):ifv=0then820
800 x=x+1:ifx<151thena=v*e:goto760
810 f$=f$+"..."
820 print"[147][212]he base";s;"number ";n$;" is"
830 if e=10 and f$<>"0" then print" ";i$;f$;" [146]"
840 if e<>10 or f$="0" then print" ";i$;".";f$;" [146]"
850 print"when expressed in base";e:goto110
860 s=e:if e=10 and f$<>"0" then n$=i$+f$
870 if e<>10 or f$="0" then n$=i$+"."+f$
880 t=0:v=0:i$="":f$="":goto370
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]"
900 print""
910 print"[194]e sure that the printer is switched on and is device #4":gosub 980
920 open3,4,7:print#3,"[212]he base";s;"number ";n$;" is"
930 if e=10 and f$<>"0" then print#3,i$;f$
940 if e<>10 or f$="0" then print#3,i$;".";f$
950 print#3,"when expressed in base";e:print#3,:close3:goto110
960 rem message centering routine
970 for mx=1 to 20-len(ms$)/2:printchr$(32);:next:printms$:return
980 print"[158]"
990 ms$="[208]ress [193]ny [203]ey [212]o [195]ontinue":gosub 960
1000 get a$:if a$="" then 1000
1010 print"":return