How to Convert Hexadecimal Numbers
Hexadecimal (base-16) is the standard compact representation for binary data in computing. It is everywhere: memory addresses in a debugger, color codes in CSS (#FF5733), SHA-256 hashes in security certificates, IPv4 addresses in routing tables, and ASCII values in character encoding references. One hex digit represents exactly 4 binary bits, so one byte (8 bits) is always exactly two hex digits — a perfect fit. This guide covers all three conversion paths out of hexadecimal with detailed worked examples, a complete digit reference table, and practical real-world applications.
The 16 Hex Digits — Complete Reference Table
Hexadecimal extends the familiar 0–9 digits with six letters A through F, representing the values 10–15 that have no single-character decimal symbol. Every hex digit maps to a unique 4-bit binary pattern — the relationship is exact and fixed. Learn this table and every hex conversion becomes a lookup rather than a calculation.
| Hex | Decimal | 4-bit Binary | Hex | Decimal | 4-bit Binary |
|---|---|---|---|---|---|
| 0 | 0 | 0000 | 8 | 8 | 1000 |
| 1 | 1 | 0001 | 9 | 9 | 1001 |
| 2 | 2 | 0010 | A | 10 | 1010 |
| 3 | 3 | 0011 | B | 11 | 1011 |
| 4 | 4 | 0100 | C | 12 | 1100 |
| 5 | 5 | 0101 | D | 13 | 1101 |
| 6 | 6 | 0110 | E | 14 | 1110 |
| 7 | 7 | 0111 | F | 15 | 1111 |
Hex → Decimal: Positional Notation
Replace each hex letter with its decimal value (A=10 through F=15), then multiply each digit by 16 raised to its positional power (rightmost = position 0), and sum all the products.
- Write the hex number and label each digit's position from 0 (rightmost) to n−1 (leftmost).
- Replace A→10, B→11, C→12, D→13, E→14, F→15. Digits 0–9 stay as-is.
- Multiply each digit value by 16^position.
- Add all products — the total is the decimal equivalent.
Worked Example 1 — Convert (1A)₁₆ to Decimal
Worked Example 2 — Convert (ABF3)₁₆ to Decimal
A four-digit hex number. Replace A=10, B=11, F=15 and apply positional weights.
| Hex digit | A | B | F | 3 |
|---|---|---|---|---|
| Decimal value | 10 | 11 | 15 | 3 |
| Position | 3 | 2 | 1 | 0 |
| Positional power | 16³=4096 | 16²=256 | 16¹=16 | 16⁰=1 |
| Product | 40960 | 2816 | 240 | 3 |
Hex → Binary: Direct 4-Bit Substitution
Since 2⁴ = 16, every hex digit maps to exactly 4 binary bits — the table above. This is the fastest conversion in number systems: no arithmetic whatsoever. Just replace each hex digit with its 4-bit binary string from the table, left to right, and concatenate.
Worked Example — Convert (ABF3)₁₆ to Binary
| Hex digit | A | B | F | 3 |
|---|---|---|---|---|
| 4-bit binary | 1010 | 1011 | 1111 | 0011 |
Worked Example — Convert (FF)₁₆ to Binary
| Hex digit | F | F |
|---|---|---|
| 4-bit binary | 1111 | 1111 |
Hex → Octal: Via Binary
There is no direct hex-to-octal table (16 and 8 don't share a simple power relationship), so binary serves as the bridge. Expand each hex digit to 4 bits, concatenate, then regroup into 3-bit chunks from right to left (padding the leftmost group with zeros if necessary), and convert each 3-bit group to an octal digit.
- Replace each hex digit with its 4-bit binary equivalent.
- Concatenate all bits into one binary string.
- Pad the leftmost end with zeros until the length is a multiple of 3.
- Split into 3-bit groups from right to left.
- Convert each 3-bit group to an octal digit (0–7).
Worked Example — Convert (FC)₁₆ to Octal
Step 1: F=1111, C=1100 → binary string 11111100 (8 bits). Step 2: pad to 9 bits → 011111100. Step 3: groups of 3: 011 | 111 | 100.
| 3-bit group | 011 | 111 | 100 |
|---|---|---|---|
| Octal digit | 3 | 7 | 4 |
Real-World Hexadecimal — Where You See It
| Context | Example | Decoded meaning |
|---|---|---|
| CSS web color | #FF5733 | R=255, G=87, B=51 (a warm red-orange) |
| ASCII letter 'A' | 0x41 | Decimal 65 → binary 01000001 |
| Max 1 byte | 0xFF | Decimal 255 → all 8 bits set: 11111111 |
| IPv4 loopback | 0x7F000001 | 127.0.0.1 — 4 bytes, each pair is one octet |
| SHA-256 constant | 0x6a09e667 | First of eight initial hash values |
- Hexadecimal Converter — Convert hex numbers to binary, octal, and decimal instantly
- Hexadecimal Conversion Formula — Positional notation formula with A–F digit values explained
Frequently Asked Questions
Are hex digits A–F case-sensitive?
No. 'A' and 'a' represent exactly the same value (10). Uppercase is conventional in hardware documentation, memory dumps, and assembly language. Lowercase is common in CSS colors (#ff5733) and cryptographic hashes. Both are fully equivalent — this converter accepts either.
Why does 0xFF mean 255?
FF in hex means F (15) at position 1 and F (15) at position 0. Expanding: 15×16 + 15 = 240 + 15 = 255. In binary, FF = 11111111 — all eight bits of one byte are set to 1. This is the maximum value that fits in a single byte, which is why you see FF so often in color codes, network masks (255.255.255.0), and memory initialization.
How do I decode a hex color code like #3498DB?
Split the 6 characters into three 2-digit pairs: R=34, G=98, B=DB. Convert each pair independently: 34₁₆ = 3×16+4 = 52, 98₁₆ = 9×16+8 = 152, DB₁₆ = 13×16+11 = 219. So #3498DB is RGB(52, 152, 219) — a medium blue.
What does the 0x prefix mean before a hex number?
0x is the standard C-language prefix indicating a hexadecimal literal, adopted by most programming languages (Java, JavaScript, Python, Rust, Go, etc.). For example, 0xFF means the hex value FF = decimal 255. Other notations you may see: FFh or FFH (assembly language), FF₁₆ (mathematics), and #FF (CSS colors).