The hexadecimal number system has 16
digits:
Hex digit: 0 1 2 3 4 5 6 7 8 9 A B C D E F
Decimal value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
To figure the decimal value of a hexadecimal number:
Step 1:Let N equal the value of the leftmost hex digit. Cross out this hex digit.
Step 2:If there are no hex digits left, STOP. The result is the current value of N.
Step 3:Increase N by a factor of 16. (Why 16? Hexadecimal is base 16)
Step 4:Increase N by the value of the leftmost hex digit. Cross out this hex digit.
Step 5:Go to Step 2.
Example: Convert 0xD5C0 to decimal.
The "0x" at the beginning is not part of the number. It just means that what follows is a number in hexadecimal.
Hex Value
digits of N Step Explanation
------ ------- ---- -----------------------------
D5C0 START
5C0 13 1 Value of D is 13,
Crossed out D, set N=13
5C0 13 2 Keep going
5C0 208 3 13*16=208, set N=208
C0 213 4 208+5=213,
Crossed out 5, set N=213
C0 213 5 Go to step 2
C0 213 2 Keep going
C0 3408 3 213*16=3408, set N=3408
0 3420 4 Value of C is 12, 3408+12=3420
Crossed out C, set N=3420
0 3420 5 Go to step 2
0 3420 2 Keep going
0 54720 3 3420*16=54720, set N=54720
54720 4 54720+0=54720
Crossed out 0, N still is 54720
54720 5 Go to step 2
54720 2 STOP. Result = 54720.
However, if it is just a 2-digit hex number, the formula is VERY easy: ((first digit) * 16) + (second digit)
Examples:
0x37 = 3*16+7 = 55
0x8F = 8*16+15 = 143 (Remember, F in hex means fifteen. See table of hex digits.)
Hexadecimal is often used because numbers in computing come out even in hexadecimal more often than in decimal.
1 kilobyte = 1,024 bytes = 0x400 bytes
1 megabyte = 1,048,576 bytes = 0x100000 bytes
Hexadecimal is often used in reference to the RGB color code.