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:

Hexadecimal Binary Decimal
016 02 010
116 12 110
216 102 210
316 112 310
416 1002 410
516 1012 510
616 1102 610
716 1112 710
816 10002 810
916 10012 910
A16 10102 1010
B16 10112 1110
C16 11002 1210
D16 11012 1310
E16 11102 1410
F16 11112 1510

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

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Digg
  • StumbleUpon
  • Technorati

Leave a Reply

You must be logged in to post a comment.