The nibble connection
Here's the entire relationship in one fact: 16 = 2⁴, so one hexadecimal digit represents exactly four bits. Four bits are called a nibble (half a byte — yes, it's a pun). A nibble holds values 0–15, which is precisely the range of one hex digit:
| Binary (nibble) | Hex | Decimal |
|---|---|---|
| 0000 | 0 | 0 |
| 0001 | 1 | 1 |
| 0101 | 5 | 5 |
| 1001 | 9 | 9 |
| 1010 | A | 10 |
| 1101 | D | 13 |
| 1111 | F | 15 |
Because of this exact fit, hex and binary convert by substitution, not arithmetic. No division, no multiplication — just table lookup.
The 4-bit grouping trick
Binary → hex: split the bits into groups of four, starting from the right. Pad the leftmost group with leading zeros if needed. Then swap each group for its hex digit.
Take 101101: group as 0010 1101 → 2 D → 2D.
Hex → binary: expand each hex digit into its 4-bit group. A5 → 1010 0101. That's it — the whole conversion, doable in your head in seconds with a little practice.
Compare that with binary ↔ decimal, which needs real arithmetic (repeated division or place-value sums). This effortlessness is why hex won as the binary shorthand: it preserves the bit structure. You can still see the bits inside A5 in a way you never could inside 165.
A worked round-trip
Convert 0x3F7 to binary, then to decimal:
- Hex → binary: 3→0011, F→1111, 7→0111, giving
0011 1111 0111(drop the leading zeros:1111110111). - Binary → decimal: place values give 512 + 256 + 128 + 64 + 32 + 0 + 4 + 2 + 1 = 1015.
- Check via hex: 3×256 + 15×16 + 7 = 768 + 240 + 7 = 1015. ✓
When to use which
| Situation | Better choice | Why |
|---|---|---|
| Reasoning about individual bits or flags | Binary | each bit is visible |
| Reading a color code (#FF5733) | Hex | compact, byte-aligned |
| Debugging memory addresses | Hex | maps cleanly to bytes |
| Designing logic circuits | Binary | gates operate on bits |
| Showing a hash or key | Hex | half the length of binary |
Rule of thumb: binary for bit-level thinking, hex for byte-level reading. They're the same information — hex just respects your time.
Hex in real code
The binary↔hex relationship shows up constantly in programming. Bit masks are the classic case: instead of writing 0b11110000, C and Python programmers write 0xF0 — and because each hex digit is one nibble, you can still see that the top four bits are set and the bottom four are clear. Reading 0xF0, an experienced developer pictures 1111 0000 instantly.
You'll also meet hex in bit shifting (1 << 4 equals 0x10), color manipulation (masking 0xFF0000 isolates the red channel), and protocol debugging, where packet dumps are printed in hex precisely because every byte stays visually distinct. Once the nibble mapping is muscle memory, hex stops feeling like a separate system and starts feeling like binary with the tedium removed.
Try it yourself
Convert between hex, binary and decimal and watch all three representations update together.
Key takeaways
- One hex digit = exactly four bits (a nibble), because 16 = 2⁴.
- Binary ↔ hex converts by substitution, not arithmetic — group bits in fours.
- Hex preserves bit structure: you can still see the nibbles inside A5.
- Use binary for bit-level reasoning, hex whenever humans need to read bytes.
Frequently asked questions
What is the relationship between binary and hexadecimal?
They encode the same values differently. One hex digit always equals exactly four binary digits (a nibble), because 16 = 2⁴. Hex is simply binary written compactly.
How do I convert binary to hex quickly?
Group the bits in fours from the right, then replace each group with its hex digit. 101101 becomes 0010 1101 → 2D. No arithmetic needed.
What is a nibble?
Four bits — half a byte. The name is a pun on byte (a nibble is a small bite). One nibble holds values 0–15, which is exactly one hexadecimal digit.
When should I use hex instead of binary?
Whenever humans need to read the value: debugging, color codes, memory addresses, hashes. Use binary when reasoning about individual bits, flags or logic circuits.