See all articles from QL Hacker's Journal 15
In some postings in on Usenet, there have been some conversations about converting from different bases. I found this task interesting and thought I’d give it a try. I did fairly well in writing a routine that would convert from Base X to Base 10. Converting from base 10 to base X was more difficult. It got the the point that I decided to give up (my programming time is limited these days, so I hate to bang my head against a programming wall). As a textbook would say “I’ll leave it as an exercise for the reader.”
100 DEFine FuNction base_ten(num$,origin_base)
110 LOCal x,y,z,total
120 total = 0
130 FOR x = LEN(num$) TO 1 STEP -1
140 y = CODE(num$(x))
150 IF y<65 THEN z = num$(x)
160 IF y>=65 AND y<=90 THEN z = y-54
170 IF y >97 AND y<=122 THEN z = y-86
180 total = total+(z*(origin_base^(LEN(num$)-x)))
190 NEXT x
200 RETurn total
210 END DEFine