--- title: "Base Conversion" type: "article" slug: "base-conversion" url: "http://localhost/article/base-conversion/" markdown_url: "http://localhost/article/base-conversion.md" published_at: "2025-11-30T07:52:20+00:00" modified_at: "2026-06-21T23:37:30+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "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.…" category: - name: "QL Hacker's Journal" slug: "ql-hackers-journal" taxonomy: "category" url: "http://localhost/category/periodicals/ql-hackers-journal/" post_tag: - name: "Full Text" slug: "fulltext" taxonomy: "post_tag" url: "http://localhost/tag/fulltext/" - name: "QL" slug: "ql" taxonomy: "post_tag" url: "http://localhost/tag/ql/" - name: "Superbasic (programming language)" slug: "superbasic-programming-language" taxonomy: "post_tag" url: "http://localhost/tag/superbasic-programming-language/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Sinclair QL" slug: "sinclair-ql" taxonomy: "model" url: "http://localhost/model/sinclair-ql/" indiv: - name: "Tim Swenson" slug: "tim-swenson" taxonomy: "indiv" url: "http://localhost/indiv/tim-swenson/" publication_r: id: 33686 title: "QL Hacker’s Journal" type: "periodical" url: "http://localhost/periodical/ql-hackers-journal/" authors_r: - name: "Tim Swenson" slug: "tim-swenson" taxonomy: "indiv" url: "http://localhost/indiv/tim-swenson/" issue: "15" issues_articles: - id: 61551 title: "QL Hacker’s Journal 15" type: "issue" url: "http://localhost/issue/ql-hackers-journal-15/" pubdate: "October 1993" archive_link: true --- # Base Conversion 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 ```