Binary numbers
Decimal to binary
Goal: Convert decimal numbers to binary · 8 min
Two methods give the same result.
1. Subtract powers of two (good for small numbers): take the largest power of 2 that fits, set that bit, subtract, repeat. 45 = 32 + 8 + 4 + 1 → 101101₂.
2. Divide by 2 repeatedly and write down the remainders; read them bottom to top: 45 : 2 = 22 r 1, 22 : 2 = 11 r 0, 11 : 2 = 5 r 1, 5 : 2 = 2 r 1, 2 : 2 = 1 r 0, 1 : 2 = 0 r 1 → 101101₂.
Check by converting back: 32 + 8 + 4 + 1 = 45. ✓
Worked example: Converting 100
- Largest power ≤ 100 is 64; remainder 36.
- 32 fits → remainder 4; 16 and 8 do not fit; 4 fits → 0.
- Bits 64, 32, 4 → 1100100₂.