Sixteen digits, including letters
Hexadecimal ("hex" for short) is the base-16 positional number system. Sixteen needs sixteen distinct digit symbols, so after 0–9 it borrows the letters A–F for the values 10–15:
| Hex | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| Hex | 8 | 9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|---|
| Decimal | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
The letters aren't mysterious — they're just single-character symbols for "ten" through "fifteen", so each hex digit still occupies one character. Case doesn't matter: ff and FF are the same value.
Why hex exists: binary is unreadable
The magic property: one hex digit = exactly four bits (a nibble), because 16 = 2⁴. So an 8-bit byte is always exactly two hex digits:
| Binary | Hex | Decimal |
|---|---|---|
| 0000 0000 | 00 | 0 |
| 0010 1101 | 2D | 45 |
| 1111 1111 | FF | 255 |
| 1010 0101 | A5 | 165 |
FF is infinitely easier to read, say and remember than 11111111 — and converting between them is trivial (see our binary vs hexadecimal guide). That's the whole reason hex exists: it's binary, made human-friendly.
Reading hex values
Place value works as always — columns are powers of 16 (1, 16, 256, 4096…). Take 2D:
2 × 16 + 13 × 1 = 32 + 13 = 45. And FF = 15 × 16 + 15 = 255 — the largest single byte, matching binary 11111111 exactly. One more, with three digits: 1A3 = 1 × 256 + 10 × 16 + 3 = 256 + 160 + 3 = 419.
You'll often see hex with a 0x prefix — 0x2D — which is just the standard way programming languages say "this number is hexadecimal". It dates back to C and is now used in Python, JavaScript, Java and many others.
Where you'll meet hex in the wild
- Colors:
#FF5733is red=FF (255), green=57 (87), blue=33 (51) — three bytes, one per channel. - Memory addresses: debuggers show addresses like
0x7ffee4a3b8because hex lines up with byte boundaries. - Unicode: characters are identified as code points like U+0041 ("A") or U+1F600 (😀).
- Networking: IPv6 addresses and MAC addresses (
AA:BB:CC:DD:EE:FF) are hex. - Cryptography: hashes and keys are displayed as hex strings.
Notice the pattern: hex shows up wherever humans need to look at raw bytes. It's the display language of low-level computing. If you open any file in a hex editor, you'll see exactly this: the file's bytes laid out as two-digit hex values, sixteen per row, with the text interpretation alongside. Forensics analysts, reverse engineers and the merely curious all read files this way — hex is the closest a human gets to seeing what the machine sees.
Try it yourself
Convert hex values to decimal and binary, and decode color codes into their red, green and blue channels.
Key takeaways
- Hexadecimal is base 16, using digits 0–9 and letters A–F (10–15).
- One hex digit always equals exactly four bits — that's what makes it useful.
- An 8-bit byte is always two hex digits (00 to FF, i.e. 0 to 255).
- The 0x prefix marks a number as hex in most programming languages.
- Hex is the standard way humans read bytes: colors, memory, hashes, MAC addresses.
Frequently asked questions
Why does hexadecimal use letters A to F?
Base 16 needs sixteen distinct digits. After 0–9 run out, the letters A–F stand in for values 10–15, so each hex digit still fits in a single character.
What does 0x mean in front of a number?
0x is the standard prefix marking a number as hexadecimal, used in C, Python, JavaScript and many other languages. 0x2D means the hex value 2D, which is 45 in decimal.
Why do programmers prefer hex over binary?
Compactness. One hex digit represents exactly four bits, so 8 bits fit in two hex digits. FF is far easier to read, write and remember than 11111111.
How do I convert hex to binary?
Replace each hex digit with its 4-bit binary equivalent: 0→0000, 1→0001 … 9→1001, A→1010, B→1011, C→1100, D→1101, E→1110, F→1111. So 2D becomes 0010 1101.