Hexadecimal is a foreign language to many of us. The decimal system is our standard. Every day math is based on the decimal system, a base 10 numbering system where every position in a base 10 number represents a number times a power of ten.
Hex is a base 16 system. In base 16, every position in a number represents a number times a power of sixteen. There are 16 digits ranging from 0 to F in the hex system. Programmers use hex because very large numbers can be stored in a smaller amount of space.
Here is how hex digits correspond to decimal equivalents.
| HEX | DECIMAL | HEX | DECIMAL | HEX | DECIMAL | ||
| 0 | 0 | 5 | 5 | A | 10 | ||
| 1 | 1 | 6 | 6 | B | 11 | ||
| 2 | 2 | 7 | 7 | C | 12 | ||
| 3 | 3 | 8 | 8 | D | 13 | ||
| 4 | 4 | 9 | 9 | E | 14 | ||
| F | 15 | ||||||
A hex viewer displays a file's structure byte by byte in hexadecimal. When viewing files in hex, it's important to have a translation chart handy, otherwise understanding is difficult. Some viewers display the ASCII character corresponding to each hex value.
Hex numbers are actually easy to translate. If a hex digit reads FF, this is 255 in decimal. Right? How is this easy?
Look at the decimal number for a second. 255 is 3 places wide. Each place represents a number times a power of ten. Starting from the right, the first place is the ones or (10^0)*n , the second place is the tens or (10^1)*n, and the third place is the hundreds or (10^2)*n. Do the multiplying and sum the three results together and the answer is 255.
In hex, the number of places are multiplied in the same manner. The hex number FF is two places wide. Hex F is decimal 15. The first place is (16^0)*n. Because n = F, the answer is 15 (1*15). The second place is (16^1)*n or 240 (16*15). Add both results and the answer is 255.