--- title: "Using BIN Within a Program" type: "article" slug: "using-bin-within-a-program" url: "http://localhost/article/using-bin-within-a-program/" markdown_url: "http://localhost/article/using-bin-within-a-program.md" published_at: "2024-07-05T17:13:02+00:00" modified_at: "2026-08-09T10:16:47+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "On page five of the April issue of The Data Expansion (Timex Tips) a routine to convert binary to decimal was given in response to a question about using BIN in programming mode. This short article describes the format to use to make this function work: When you enter the BIN function in command mode,…" category: - name: "The Data Expansion" slug: "the-data-expansion" taxonomy: "category" url: "http://localhost/category/periodicals/the-data-expansion/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Mike Hart" slug: "mike-hart" taxonomy: "indiv" url: "http://localhost/indiv/mike-hart/" publication_r: id: 50143 title: "The Data Expansion" type: "periodical" url: "http://localhost/periodical/the-data-expansion/" authors: "Mike Hart" authors_r: - name: "Mike Hart" slug: "mike-hart" taxonomy: "indiv" url: "http://localhost/indiv/mike-hart/" volume: "4" issue: "10" issues_articles: - id: 50238 title: "The Data Expansion v4 n10" type: "issue" url: "http://localhost/issue/the-data-expansion-v4-n10/" pages: "16-17" pubdate: "October 1987" archive_link: false --- # Using BIN Within a Program On page five of the April issue of The Data Expansion (Timex Tips) a routine to convert binary to decimal was given in response to a question about using BIN in programming mode. This short article describes the format to use to make this function work: When you enter the BIN function in command mode, the syntax editor automatically converts the argument (following the BIN token) into the Timex five-byte (intergral) number and inserts it (invisibly) directly following the argument. The syntax of the BIN function only allows a direct argument. That is to say, it will not accept any indirect’ argument (a variable or string syntax editor, and the cursor will display after the BIN token). To use the BIN function within a Basic program, you have to get around its limitations. The best way I’ve found is to use the VAL function, which has the same syntax as the INPUT command. You still can’t use indirect references in the argument string of the VAL function (i.e. dec=VAL “BIN A” or dec=VAL “BIN a$” message, either will produce an error message). But if you go one step further, you can get the BIN function to work. Type in this short program: ``` 10 INPUT Binary #";b$ 20 LET b$="BIN "+b$ 30 PRINT "Decimal = "; VAL b$ ``` At the prompt, enter your binary number to be converted to decimal. The program will print out the decimal value. I have seen other binary-to-decimal programs, but the BIN function is both faster and shorter than any other I have seen in use.