--- title: "Decimal/Hex/Bin Convertor" id: 80728 type: "computer_media" slug: "decimal-hex-bin-convertor" url: "http://localhost/computer_media/decimal-hex-bin-convertor/" markdown_url: "http://localhost/computer_media/decimal-hex-bin-convertor.md" published_at: "2026-11-26T19:45:49+00:00" modified_at: "2026-11-26T19:45:49+00:00" featured_image: url: "http://localhost/wp-content/uploads/2026/11/decimal-hex-bin-convertor-1.png" excerpt: "Decimal to hex, hex to decimal and binary to decimal converter for the TS2068." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Vincent Lyon" slug: "vincent-lyon" taxonomy: "indiv" url: "http://localhost/indiv/vincent-lyon/" genre: - name: "Utility" slug: "utility" taxonomy: "genre" url: "http://localhost/type/utility/" media_type: "Program" programmers: - name: "Vincent Lyon" slug: "vincent-lyon" taxonomy: "indiv" url: "http://localhost/indiv/vincent-lyon/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Decimal-Hex-Bin%20Convertor%20%281984%29%28Lyon%2C%20Vincent%29%28TS2068%29%28US%29%28Program%29.zip" tsrun_member: "Decimal-Hex-Bin Convertor (1984)(Lyon, Vincent)(TS2068)(US)(Program)/Decimal-Hex-Bin Convertor (1984)(Lyon, Vincent)(TS2068)(US)(Program).tap" mediadate: "1984" images: - url: "http://localhost/wp-content/uploads/2026/11/decimal-hex-bin-convertor-1.png" - url: "http://localhost/wp-content/uploads/2026/11/decimal-hex-bin-convertor-2.png" - url: "http://localhost/wp-content/uploads/2026/11/decimal-hex-bin-convertor-3.png" - url: "http://localhost/wp-content/uploads/2026/11/decimal-hex-bin-convertor-4.png" - url: "http://localhost/wp-content/uploads/2026/11/decimal-hex-bin-convertor-5.png" - url: "http://localhost/wp-content/uploads/2026/11/decimal-hex-bin-convertor-6.png" article_media: - id: 44753 title: "Small Tool" type: "article" url: "http://localhost/article/small-tool/" media_type_tags: "Utility" license: false --- # Decimal/Hex/Bin Convertor A small menu-driven tool for machine code and user-graphics work: 1 converts a decimal number to four-digit hex, 2 a four-digit hex number to decimal, 3 an eight-digit binary number to decimal, and 4 ends the program (press ENTER to clear memory with NEW). Hex must be typed as four digits (05C3, not 5C3; caps lock is switched on for it), and binary as exactly eight digits, or it tells you there were not enough or too many. Corrected so it runs: line 1018 was printed PRINT AT ,15,0 (with a stray comma), which stops the program with Nonsense in BASIC as soon as the menu appears; it now reads PRINT AT 15,0. The author notes a TS1000 version could be written by changing the CHR$ codes; only the TS2068 version is printed. Published in The Plotter December 1984 ([Small Tool](https://timexsinclair.com/article/small-tool/)). ## Source Code ``` 5 CLS 10 GO TO 1000 100 DIM H$(4) 105 LET p=4 110 LET h$="0000" 115 PRINT AT 20,0;" ";AT 20,0; FLASH 1;">"; FLASH 0;" Enter the decimal number." 120 INPUT d 122 LET e=d 125 PRINT AT 20,0;" " 130 LET n=INT (d/16) 131 LET rr=(d-16*n+48) 132 IF rr>57 THEN LET rr=rr+7 135 LET h$(p)=CHR$ (rr) 140 LET d=n 145 LET p=p-1 150 IF d>0 THEN GO TO 130 160 PRINT AT 20,0;e;" Hex Value is ";h$ 170 GO TO 1000 200 PRINT AT 20,0;" ";AT 20,0; FLASH 1;">"; FLASH 0;" Enter the four digit hex." 202 POKE 23658,8 205 INPUT h$ 210 LET d=0 215 FOR p=1 TO 4 217 LET rr=(CODE (h$(p))-48) 218 IF rr>9 THEN LET rr=rr-7 220 LET d=d*16+(rr) 225 NEXT p 230 PRINT AT 20,0;" ";AT 20,0;h$;" Decimal value is ";d 235 POKE 23658,0 240 GO TO 1000 300 DIM a$(8) 305 LET o=0 307 PRINT AT 21,9;"▒" 310 PRINT AT 20,0;" ";AT 20,0; FLASH 1;">"; FLASH 0;" Enter BIN code." 314 INPUT b$ 315 LET a$=b$ 316 LET i=LEN b$ 317 IF i<>8 THEN GO TO 400 320 LET b=128 330 FOR f=1 TO 8 340 LET q=VAL a$(f) 350 LET o=o+(q*b) 360 LET b=b/2 370 NEXT f 375 PRINT AT 21,9;" " 380 PRINT AT 20,0;" ";AT 20,0;a$;" BIN is ";o;" decimal." 390 GO TO 1000 400 IF i<8 THEN PRINT FLASH 1;AT 20,0;" NOT ENOUGH DIGITS WERE ENTERED " 410 IF I>8 THEN PRINT FLASH 1;AT 20,0;" TOO MANY DIGITS WERE ENTERED " 420 PAUSE 100 430 PRINT AT 20,0;" " 440 GO TO 300 500 CLS 510 PRINT AT 10,0;"▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒";AT 12,4;"EXIT COMMAND EXECUTED"," PRESS ENTER TO CLEAR MEMORY";AT 15,0;"▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒" 515 PAUSE 4E4 520 NEW 1000 PRINT AT 5,0;"▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒";AT 7,3; INVERSE 1;"DECIMAL/HEX/BIN CONVERTOR"; 1010 PRINT AT 9,6;"1) DECIMAL TO HEX";AT 10,6;"2) HEX TO DECIMAL";AT 11,6;"3) BIN TO DECIMAL";AT 12,6;"4) EXIT PROGRAM" 1015 PRINT AT 13,0;"▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒" 1017 PRINT ,," Enter your choice 1 to 4" 1018 PRINT AT 15,0; FLASH 1;">" 1019 BEEP .15,10 1020 INPUT S 1025 PRINT AT 15,0;" " 1030 IF S<1 OR S>4 THEN GO TO 1000 1035 IF S=4 THEN LET S=5 1040 GO TO S*100 1050 STOP 1060 SAVE "conv" LINE 1 ```