Base Converter guide
How to Convert Hexadecimal to Decimal
Hexadecimal uses sixteen digits: 0 to 9, then A to F for the values 10 to 15. To convert to decimal, give each digit a place value that multiplies by 16 from right to left, then add the results. FF is (15 × 16) + 15 = 255.
The letters are digits
Hexadecimal needs sixteen different digits, but we only have ten number symbols. So the first six letters of the alphabet fill in for the rest.
| Hex | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| Decimal | 10 | 11 | 12 | 13 | 14 | 15 |
Place values multiply by 16
Where decimal places are 1, 10, 100, 1000 and binary places are 1, 2, 4, 8, hexadecimal places are 1, 16, 256, 4096.
Each position is worth sixteen times the one to its right. That is the entire structure.
For FF: the left F is in the 16s place and the right F is in the 1s place. F is 15, so that is (15 × 16) + (15 × 1) = 240 + 15 = 255.
A longer example
Take 2AF. Three digits, so the place values are 256, 16 and 1.
2 is in the 256s place: 2 × 256 = 512.
A is 10, in the 16s place: 10 × 16 = 160.
F is 15, in the 1s place: 15 × 1 = 15.
Adding: 512 + 160 + 15 = 687.
The only genuinely new skill here is remembering the letter values. Everything else is the same place-value arithmetic you already do.
Spotting a hex number in the wild
Hex is usually marked so you know it is not decimal, and the notation varies by context:
- 0x2AF — the C, Java, JavaScript and Python convention
- #FF7F50 — CSS and design tools, for colours
- 2AFh — assembly language
- $2AF — older systems and some calculators
Why two hex digits are so convenient
Two hex digits cover exactly 0 to 255 — precisely the range of one byte. That is not a coincidence, and it is the main reason hex is used at all.
It means a byte is always written as exactly two hex characters, never one and never three. Memory dumps, colour codes and file formats all line up neatly in columns because of it.
The same number in binary would need eight characters and be far harder to read at a glance. FF is easier to scan than 11111111, and they mean the same thing.
Why programmers use it
DEADBEEF is a magic number — a recognisable value deliberately written into memory so that it stands out later.
If a program reads a variable and finds DEADBEEF, that variable was almost certainly never properly initialised. Random junk memory very rarely spells anything, so seeing a word is a strong signal that something is wrong.
It also fills exactly 32 bits, which made it a natural fit for older systems where a machine word was that size.
Other hex words
- CAFEBABE — the first four bytes of every compiled Java class file.
- DEADC0DE — used as a marker in some firmware, with a zero standing in for the O.
- BAADF00D — used by Microsoft debug builds to fill memory that has been allocated but not yet written to.
- FEEDFACE — appears in Mach-O binaries on macOS.
- 8BADF00D — an iOS crash code, meaning the app took too long to launch. It reads as "ate bad food".