Core answer: Every base-N number is a polynomial in N: 1011 in binary = 1×2³ + 0×2² + 1×2 + 1 = 11 in decimal. To convert decimal to base N, repeatedly divide by N and read remainders bottom-up: 11 → 1011. Hex is just 4-bit groups: 1011 = B, so binary ↔ hex is trivial once you memorize 16 patterns.
The positional-value idea
Digits are coefficients of powers of the base, written most-significant first:
| Number | Expansion | Decimal |
|---|---|---|
| 1011₂ | 8+0+2+1 | 11 |
| 37₈ | 3×8 + 7 | 31 |
| 2F₁₆ | 2×16 + 15 | 47 |
| 255 | 2×100 + 5×10 + 5 | 255 |
Converting decimal → base N (divide-and-remainder)
156 to hex: 156 ÷ 16 = 9 r 12(C); 9 ÷ 16 = 0 r 9. Read remainders upward: 9C. Check: 9×16 + 12 = 156. ✓
50 to binary: 50→25 r0; 25→12 r1; 12→6 r0; 6→3 r0; 3→1 r1; 1→0 r1 → 110010. Check: 32+16+2 = 50. ✓
Binary ↔ hex/octal shortcuts
Group bits in fours (hex) or threes (octal) from the right:
1110 0101₂ = E5₁₆. That is why programmers think in hex: one hex digit = exactly 4 bits, two digits = one byte. 0xFF = 255 = 1111 1111 — a full byte.
Why computers live in base 2 (and humans peek in base 16)
- A transistor is on or off — two states map to 0/1.
- IPv4 addresses are 4 bytes: 192.168.1.1 = C0 A8 01 01 in hex.
- Color codes are 3 bytes: #FF8000 = red 255, green 128, blue 0.
- File permissions 755 in Unix are octal: rwx r-x r-x.
Common mistakes and myths
- Reading remainders top-down — the answer is built *bottom-up*; 156 to hex is 9C, not C9.
- Forgetting that 0x10 is 16, not 10 — leading "0x" means hex; "10" alone means ten. Context is everything.
- Counting from digit 1 instead of digit 0 — the rightmost digit is N⁰ = 1's place; 8-bit numbers hold 0–255 (256 values), not 0–256.
- Assuming decimals convert finitely — 0.1 has no finite binary form (0.0001100110011…), which is why 0.1 + 0.2 ≠ 0.3 in floating point.
- Confusing base with value — 11 in binary is 3; in octal, 9; in hex, 17. Always state the base.