Computer Math, Part 4: Hexadecimal

Now that you understand binary, let’s move onto hexadecimal, or base 16. This is the numbering system most programmers use, because it translates easily to and from binary. Also, 2 hexadecimal digits make up a byte, or 8 bits.

How do we have 16 digits? Simple, hexadecimal uses the digits 0-9 and the letter A-F. 0-9 is the same in hexadecimal as decimal. The digits A-F in hexadecimal are 10-15 in decimal. Here is a conversion chart of single digit hexadecimal:

HexadecimalBinaryDecimal
01602010
11612110
216102210
316112310
4161002410
5161012510
6161102610
7161112710
81610002810
91610012910
A16101021010
B16101121110
C16110021210
D16110121310
E16111021410
F16111121510

Hexadecimal, sometimes simply called hex, is very easy to translate to and from binary. This is because each digit in hex is 4 digits in binary. All you have to do is replace the hexadecimal digit with the binary equivalent. For instance, the number FF16 is 111111112.

Converting a binary number to hex works just slightly different. When you convert a number from hex to binary, you can work from left to right or right to left. When you convert a number from binary to hex, you must work from right to left. This is because a binary number might not be the correct length to work from left to right.

That’s all for today, check back Friday for Octal, or base 8. Here’s some homework:

Convert the following hexadecimal numbers to binary and decimal:
A216
FFFFFF16
10016
CCCCCC16
A2B16
FA6F16
12316
32116
100016
1000016