2.1.3 Denary–binary conversion
Converting Denary to Binary
There are two standard methods for converting a positive denary integer to binary. Both produce the same result — choose whichever you find clearer.
Write the column values (128, 64, 32, 16, 8, 4, 2, 1). Working left to right, place a 1 in each column if its value is less than or equal to the remaining total, then subtract it; otherwise place a 0.
Example: convert 185 to 8-bit binary
- 128 ≤ 185? Yes → bit = 1, remaining = 185 − 128 = 57
- 64 ≤ 57? No → bit = 0
- 32 ≤ 57? Yes → bit = 1, remaining = 57 − 32 = 25
- 16 ≤ 25? Yes → bit = 1, remaining = 25 − 16 = 9
- 8 ≤ 9? Yes → bit = 1, remaining = 9 − 8 = 1
- 4 ≤ 1? No → bit = 0
- 2 ≤ 1? No → bit = 0
- 1 ≤ 1? Yes → bit = 1, remaining = 0
Result: 10111001
Repeatedly divide the number by 2. Record the remainder (0 or 1) each time. When the quotient reaches 0, stop. The binary number is the remainders read from bottom to top.
Example: convert 185 to binary
| Division | Quotient | Remainder |
|---|---|---|
| 185 ÷ 2 | 92 | 1 ← LSB |
| 92 ÷ 2 | 46 | 0 |
| 46 ÷ 2 | 23 | 0 |
| 23 ÷ 2 | 11 | 1 |
| 11 ÷ 2 | 5 | 1 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 ← MSB |
Reading remainders bottom to top: 10111001
Converting Binary to Denary
Write the column values above each bit. Multiply each bit by its column value and sum the results. Only positions with a 1 contribute.
Example: convert 11010110 to denary
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 1 | 0 | 1 | 1 | 0 |
128 + 64 + 16 + 4 + 2 = 214
Converting Negative Values (Two's Complement)
To convert a negative denary value to two's complement binary:
- Convert the positive version of the number to binary.
- Invert all bits.
- Add 1.
Example: convert −53 to 8-bit two's complement
- +53 = 32 + 16 + 4 + 1 →
00110101 - Invert:
11001010 - Add 1:
11001011
Verify: −128 + 64 + 8 + 2 + 1 = −128 + 75 = −53 ✓
To convert a two's complement binary number with MSB=1 back to denary: use the negative column value (−128 for 8-bit) for the MSB, then add the remaining positive column values normally.
Key Takeaways
- Denary → binary: column method (greedy subtraction) or repeated division by 2 (remainders read bottom-up).
- Binary → denary: sum the active column values (128, 64, 32, 16, 8, 4, 2, 1).
- For negative numbers: convert positive version, invert all bits, add 1.
- Always pad to the required number of bits with leading zeros.