Classic Computer Magazine Archive COMPUTE! ISSUE 50 / JULY 1984 / PAGE 6

Hex-To-Decimal Conversions

As a faithful reader of your magazine, I'd like to say that I'm surprised at how many computer hobbyists still have not found a simple decimal-to-hexadecimal conversion program. And I haven't noticed one in any issue of your magazine, so I've written this short BASIC program to do the conversions. It will work on most computers with little or no modification.

Frank Sgabellone

10 A$ = "0123456789ABCDEF": INPUT "DEC/HEX"; A
      : B = 1: C = 9: D = 16↑C: PRINT A; " = $": A = A+1 :rem 107
20 IF A-D>0 THEN A = A - D: B = B + 1: GOTO 20 :rem 156
30 PRINTMID$ (A$, B, 1);: B = 1: C = C - 1: D = 16↑C: IF C
      >-1 THEN 20 :rem 235
40 PRINT "{5 SPACES}": GOTO 10 :rem9

Hexadecimal numbers are widely used in machine language since they are more convenient for that kind of programming than the normal decimal numbers.