Hexadecimal
The Problem With Reading Binary
Binary is perfect for machines and miserable for humans. Quick — are these two the same?
10110100111000101101011100101111
10110100111000101101011100101111
They are, but your eyes hate checking. Binary strings are long, repetitive, and error-prone to read, copy, or say aloud. Decimal doesn't rescue us: converting to base 10 is awkward (each decimal digit doesn't line up with any clean group of bits).
So computing adopted a third system: hexadecimal (hex for short) — base 16. It exists for one reason: it is binary in compact form.
Sixteen Digits
Base 16 needs sixteen digit symbols. We have 0–9… then we borrow letters:
| Hex digit | 0–9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|
| Value | 0–9 | 10 | 11 | 12 | 13 | 14 | 15 |
So counting in hex goes: …8, 9, A, B, C, D, E, F, 10, 11… where hex 10 is decimal 16. (Yes, "10" means sixteen here. Every base's "10" means that base. This is also the punchline of an old joke: there are 10 kinds of people — those who understand binary and those who don't.)
Place values work exactly like binary's doubling and decimal's tens — but multiply by 16: …, 4096, 256, 16, 1.
- Hex
2A= (2 × 16) + 10 = 42 - Hex
FF= (15 × 16) + 15 = 255
That last one explains a number you keep meeting: 255 is FF — one byte, all bits on, the top of every 0–255 range in colour values and beyond.
The Magic Alignment: One Hex Digit = Four Bits
Here is why base 16 was chosen and not, say, base 12. Since 16 = 2⁴, each hex digit corresponds to exactly four bits — a perfect, lossless grouping:
| Binary | Hex | Binary | Hex | |
|---|---|---|---|---|
| 0000 | 0 | 1000 | 8 | |
| 0011 | 3 | 1010 | A | |
| 0101 | 5 | 1100 | C | |
| 0111 | 7 | 1111 | F |
To convert binary → hex, chop into groups of four and translate each group; no arithmetic needed:
1011 0100 1110 0010
B 4 E 2 → B4E2
Sixteen unreadable bits become four crisp characters — a quarter of the length, and each character still tells you exactly which four bits it stands for. Decimal can't do this trick; hex is not a different number so much as a better font for binary.
Where You'll Meet Hex
Once you know its face, hex is everywhere:
- Web colours —
#FF8000is #RRGGBB: two hex digits (one byte, 0–255) per channel of red, green, blue. FF red + 80 green + 00 blue = orange. Every colour picker you have ever used speaks hex. - Memory addresses — when a program crashes, errors report locations like
0x7FFC2A10(the0xprefix announces "hex"). Raw memory is binary; addresses are shown in hex to stay readable. - MAC addresses — network hardware IDs like
A4:5E:60:C2:8B:11on every device that joins a network. - Data dumps — file contents and character codes inspected byte by byte are conventionally displayed as hex pairs.
None of these are hex "underneath" — underneath is always binary. Hex is the human-facing display, a small everyday abstraction.
Try It Yourself
- Convert hex
3Cto decimal. (3 × 16 + 12 = ?) - Convert decimal 200 to hex. (How many 16s in 200? What remains?)
- Convert binary
1111 0001to hex — no arithmetic allowed, just the 4-bit table. - What colour is
#00FF00? And#000000?
Worked Example — Reading a Crash Report
Imagine an app crashes and shows this line in its error log: Error at address 0x1A3F, expected byte 0x0A, found 0xFF. Nothing here is mysterious once you can read hex:
0x1A3Fis a memory address — the specific location in RAM where something went wrong. Converting it to binary or decimal would make the log unreadable at a glance; as hex, an engineer can scan it, compare it to other addresses, and spot patterns instantly.0x0Ais a single byte (two hex digits = 8 bits), equal to decimal 10 — as it happens, this is the character code for a newline in many systems0xFFis that familiar top-of-the-byte value again: 11111111 in binary, 255 in decimal, all bits switched on
Nobody debugging this crash is thinking in binary — that would mean scanning 32 individual 1s and 0s per address. Nobody is thinking in decimal either, because decimal numbers don't reveal anything about the underlying bit patterns. Hex sits in the sweet spot: compact enough to read at speed, and precisely aligned with the bits underneath, which is exactly why every serious debugging tool displays raw memory in hexadecimal.
Converting Decimal to Hex, Step by Step
The earlier examples showed the result of decimal-to-hex conversion; here is the repeatable method, the same "does the biggest place value fit?" process used for binary:
Convert 200 to hex:
- How many 16s fit in 200?
200 ÷ 16 = 12remainder8 - 12 in hex is
C - So 200 =
C8in hex
Check it: (12 × 16) + 8 = 192 + 8 = 200. ✓ The same division-and-remainder process extends to bigger numbers by repeating: divide by 16, note the remainder, divide the quotient by 16 again, and read the remainders from last to first.
Key Words
- Hexadecimal (hex) — base 16, digits 0–9 and A–F
- A–F — the hex digits for values 10 to 15
- Place value — hex columns are worth 1, 16, 256, … (powers of 16)
- Nibble — four bits; exactly one hex digit
- 0x / # — common prefixes marking a number as hex (addresses / colours)