What is hexadecimal?
The hexadecimal number system is a base-16 system. Since 16 is larger than 10, it needs extra symbols beyond the usual digits. It uses 0-9 for zero to nine, then the letters A B C D E F for the values ten to fifteen.
| Hex | A | B | C | D | E | F |
| Decimal | 10 | 11 | 12 | 13 | 14 | 15 |
Key idea
Each hex position is a power of 16. Reading from right to left the place values are 1, 16 and 256. Multiply each digit by its place value and add.
Doing conversions
To convert hex to decimal, expand each digit. For example, hex 1A means (1 × 16) + (10 × 1) = 16 + 10 = 26. The largest two-digit hex value, FF, equals (15 × 16) + 15 = 255 in decimal.
Hexadecimal links neatly to binary because 16 = 2 × 2 × 2 × 2. Every hex digit maps to exactly four binary bits, so binary 1010 is hex A.
Example
Convert binary 11110000 to hex. Split into fours from the right: 1111 and 0000. That is 15 and 0, which is hex F0.
Where it is used
Programmers use hexadecimal to write colours (like #FF0000 for red), memory addresses and error codes, because it is far shorter and easier to read than plain binary. Since each hex digit is worth four bits, one byte (eight bits) fits neatly into exactly two hex digits — for example the byte 11111111 is simply FF. This tidy match with bytes is a big reason hexadecimal appears so often when we look at how a computer stores data.