Hexadecimal (better known as hex) is a base 16 number system. The decimal system is base ten. A single digit can represent values from 0 to 9. In hexadecimal, a single digit can represent values from 0 to 15.
The values 10 to 15 are represented by the letters 'a' through 'f'. So, to count from 0 to 20 in hex, you say: 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,10,11,12,13,14. (14 in hex is 20 in decimal.)

To learn how to covert numbers to hex, first you need to know about what numbers really mean.
When you say 124 in decimal, what you're really saying is 1x100 + 2x10 + 4x1, or more correctly 1x102 + 2x101 + 4x100. (If you're not using Netscape 2.0, this won't make any sense because you can't see my superscripts!)
When you say 124 in hex, you're saying 1x162 + 2x161 + 4x160, or 1x256 + 2x16 + 4x1 which is 292 in decimal.
So, to convert a number from hex to decimal, just write it out in exponential form and add everything up. (That's what I did above.)

To convert decimal to hex takes a little more math.
Take your decimal number and divide it by 16. The remainder is the "ones" digit. Divide the result by 16 again, and that remainder is the 161 digit. Keep that up until there's nothing left to divide.

Example: Convert 292 in decimal to hex.
Divide 292 by 16: 292/16 = 18 r 4 (That r means remainder.)
Divide 18 by 16: 18/16 = 1 r 2
Divide 1 by 16: 1/16 = 0 r 1

Now there's nothing more left to divide. So look back at the remainders: 4, 2, and 1. Reverse the order of those, 124, and you have the hex equivalent of decimal 292.

Now, class, for homework I want you to do problems 1 though 658347 on page 49. You may skip problem 5.

Return to the tutorial