--- title: "Hexadecimal Math" type: "article" slug: "hexadecimal-math" url: "http://localhost/article/hexadecimal-math/" markdown_url: "http://localhost/article/hexadecimal-math.md" published_at: "2026-11-28T14:10:45+00:00" modified_at: "2026-11-28T14:10:45+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "This program converts hex numbers to decimal, does the arithmetic operation, then gives the answer in hex. You can convert hex/dec in either direction. Enter 4-digit hex numbers with leading zeros. The program overflows above 7FFF. Exit by entering an invalid entry like \"VVVV\". List of Variables: N=operating array Y$=hex input H=hex number array M=multiplier…" post_tag: - name: "1981" slug: "year-1981" taxonomy: "post_tag" url: "http://localhost/tag/year-1981/" - name: "Full Text" slug: "fulltext" taxonomy: "post_tag" url: "http://localhost/tag/fulltext/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Sinclair ZX80" slug: "zx80" taxonomy: "model" url: "http://localhost/model/zx80/" indiv: - name: "James Holder" slug: "james-holder" taxonomy: "indiv" url: "http://localhost/indiv/james-holder/" publication: "Syntax" publication_r: id: 10246 title: "Syntax" type: "periodical" url: "http://localhost/periodical/syntax/" authors: "James Holder" volume: "2" issue: "12" issues_articles: - id: 82135 title: "Syntax/Syntax ZX80 v2 n12" type: "issue" url: "http://localhost/issue/syntax-syntax-zx80-v2-n12/" pages: "16" pubdate: "December 1981" archive_link: false volumeissue: "v2n12" --- # Hexadecimal Math This program converts hex numbers to decimal, does the arithmetic operation, then gives the answer in hex. You can convert hex/dec in either direction. Enter 4-digit hex numbers with leading zeros. The program overflows above 7FFF. Exit by entering an invalid entry like “VVVV”. ``` List of Variables: N=operating array Y$=hex input H=hex number array M=multiplier C=menu choice D=decimal input Q=quotient U=indirect address X=hex result pointer and FOR-NEXT loop counter ``` ``` 10 PRINT "HEXADECIMAL MATH" 20 PRINT 30 PRINT "H TO D=0, D TO H=1, H+H=2, H-H=3H*H=4, H/H=5" 40 INPUT C 50 IF C=0 THEN GO TO 300 60 IF C=1 THEN GO TO 450 70 CLS 80 IF C>5 THEN RUN 90 DIM N(1) 100 LET U=180 110 PRINT "ENTER H" 120 INPUT Y$ 130 IF C=2 THEN PRINT Y$;"+"; 140 IF C=3 THEN PRINT Y$;"-"; 150 IF C=4 THEN PRINT Y$;"*"; 160 IF C=5 THEN PRINT Y$;"/"; 170 GO TO 350 180 LET N(0)=D 190 INPUT Y$ 200 PRINT Y$;"="; 210 LET U=230 220 GO TO 350 230 LET N(1)=D 240 IF C=2 THEN LET D=N(0)+N(1) 250 IF C=3 THEN LET D=N(0)-N(1) 260 IF C=4 THEN LET D=N(0)*N(1) 270 IF C=5 THEN LET D=N(0)/N(1) 280 LET U=580 290 GO TO 500 300 LET U=430 310 PRINT "ENTER H" 320 INPUT Y$ 330 CLS 340 PRINT "H=";Y$; 350 LET M=4096 360 LET D=0 370 FOR X=0 TO 3 380 LET D=(CODE(Y$)-28)*M+D 390 LET Y$=TL$(Y$) 400 LET M=M/16 410 NEXT X 420 GO TO U 430 PRINT "D=";D; 440 RUN 20 450 LET U=570 460 PRINT "ENTER D" 470 INPUT D 480 CLS 490 PRINT "D=";D, 500 DIM H(3) 510 FOR X=0 TO 3 520 LET Q=D/16 530 LET H(X)=(D-Q*16)+28 540 LET D=Q 550 NEXT X 560 GO TO U 570 PRINT "H="; 580 PRINT CHR$(H(3));CHR$(H(2)); CHR$(H(1));CHR$(H(0)) 590 RUN 20 Syntactic Sum: 8474, 4K ```