Hexadecimal and Other Base Conversion Math for Everyone

See also my Binary Math page for an easy conversion between DEC and BIN.

1. Converting from HEX to DEC

This is just a quick primer for those wanting to learn how to convert between HEX and DEC. <Insert Christmas and Halloween Joke here.> or <Instert only you an dead people understand HEX Joke here.>

HEX numbers are composed of digits 0 through 9 like DEC but also adds A-F. So when counting in HEX:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12 ... 1A, 1B, 1C ... 1F, 20 ...

HEX 0 1 2 3 4 5 6 7 8 9 A B C D E F
DEC 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Here is a HEX number: 1E5DF
To convert this to a DEC, we need to define the base for our power function. Since HEX is based on 16 different digits [0-9A-F], our base is 16.

To convert from HEX to DEC, follow these steps:

We know that F = 15 in DEC so we use this formula(15*160) = 15
We know that D = 13 in DEC so we use this formula(13*161) = 208
We know that 5 = 5 in DEC so we use this formula(5*162) = 1280
We know that E = 14 in DEC so we use this formula(14*163) = 57344
We know that 1 = 1 in DEC so we use this formula(1*164) = 65536

Now we add all of the numebrs together to get the DEC number for HEX number 1E5DF:
15 + 208 + 1280 + 57344 + 65536 = 124383

So our answer is HEX 1E5DF = DEC 124383

2. Converting from DEC to HEX

Converting from DEC to HEX is a little more difficult. Let us start with a small DEC number. Let us use DEC 300. First we divid the DEC number by 16 (the number of digits in HEX). Now write down the remainder (300/16 = 18 remainder 12). The remainder is converted to HEX [DEC 12 = HEC C].

Now we divide 18 by 16 (18/16 = 1 remainder 2). Again, the remainder is converted to HEX [DEC 2 = HEX 2].

We divide 1 by 16 (1/16 = 0 remainder 1). Again, the remainder is converted to HEX [DEC 1 = HEX 1].

Finally, we put the numbers together. The remainder from our first division [HEX C] goes into the one place. Our remainder from our second division goes into the tens place. And our last remainder goes into the hundreds place.

So our answer is DEC 300 = HEX 12C

One more go! Let us try to convert DEC 10,000 to HEX.

DivisionQuotientRemainder
10,000/166250
625/16391
39/1627
2/1602

So our answer for DEC 10,000 = HEX 2710

3. Extending our new Knowledge

Now that we have converted from HEX to DEC, you can apply the same logic to other converstion. If we want to convert from Ternary (base of 3) we would simply replace 16N with 3N.

Here are some common base numbers:

NameBaseCounting Symbols
Binarybase 20, 1
Ternarybase 30, 1, 2
Quaternarybase 40, 1, 2, 3
Quinarybase 50, 1, 2, 3, 4
Octalbase 80, 1, 2, 3, 4, 5, 6, 7
Decimalbase 100, 1, 2, 3, 4, 5, 6, 7, 8, 9
Hexadecimalbase 160, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Vigesimalbase 200, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G, H, I, J
Alpha-Numericalbase 360, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G, H, I, J, K, L ,M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z


Let us try to convert DEC 653 to Ternary.

DivisionQuotientRemainder10NRemainder * 10NTally
653/3217210022
217/37211011012
72/3240102012
24/380103012
8/3221042000020012
2/302105200000220012

So our answer for DEC 653 = Ternary 220012


Let us try to convert Quinary 43210 to DEC.

FormulaProductTally
0 * 5000
1 * 5155
2 * 525055
3 * 53375430
4 * 5425002930

So our answer for Quinary 43210 = DEC 2930


Let us try to convert Vigesimal ICED to DEC.

FormulaProductTally
D (13) * 2001313
E (14) * 201280293
C (12) * 20248005093
I (18) * 203144000149093

So our answer for Vigesimal ICED = DEC 149093


Let us try to convert Alpha-Numerical PIZZA to DEC.

FormulaProductTally
A (10) * 3601010
Z (35) * 36112601270
Z (35) * 3624536046630
I (18) * 363839808886438
P (25) * 3644199040042876838

So our answer for Alpha-Numerical PIZZA = DEC 42876838


The generic formula to convert from a base to decimal is:

Where is the highest nth digit in the number to convert and is the base to the power of one less than the total number of digits to be converted.

4. Links

http://www.subnetonline.com/tools/dechexbin.html
http://www.comsc.ucok.edu/~mcdaniel/hex.html