Conversion between decimal and binary systems
1. Decimal to Binary (Integer Part) — Repeated Division by 2
Divide the number repeatedly by 2, note each remainder (always 0 or 1), and stop when the quotient becomes 0. Read the remainders from bottom to top.
Example: (45)₁₀ = (?)₂
| Step | Division | Quotient | Remainder |
|---|---|---|---|
| 1 | 45 ÷ 2 | 22 | 1 (LSB) |
| 2 | 22 ÷ 2 | 11 | 0 |
| 3 | 11 ÷ 2 | 5 | 1 |
| 4 | 5 ÷ 2 | 2 | 1 |
| 5 | 2 ÷ 2 | 1 | 0 |
| 6 | 1 ÷ 2 | 0 | 1 (MSB) |
Reading upwards: 101101₂. Check: ✓
2. Binary to Decimal (Integer Part) — Positional Expansion
Multiply each bit by its positional weight and add, from the right (position 0).
Example: (101101)₂ = (?)₁₀
| Position | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|
| Bit | 1 | 0 | 1 | 1 | 0 | 1 |
| Weight | 32 | 16 | 8 | 4 | 2 | 1 |
| Product | 32 | 0 | 8 | 4 | 0 | 1 |
(45)₁₀
For long patterns the doubling method is faster: start with 0 and for each bit (left to right) do double and add the bit.
1 → 1; 1 → 3; 0 → 6; 1 → 13; 1 → 27; 0 → 54; 1 → 109 (so 1101101₂ = 109₁₀).
3. Fractional Part — Repeated Multiplication by 2
Multiply the fraction by 2; the integer part produced (0 or 1) is the next binary digit; keep the fractional part and repeat. Read the digits top to bottom.
Example: (0.625)₁₀ = (?)₂
| Step | Multiply | Integer part | Fraction left |
|---|---|---|---|
| 1 | 0.625 × 2 = 1.25 | 1 | 0.25 |
| 2 | 0.25 × 2 = 0.50 | 0 | 0.50 |
| 3 | 0.50 × 2 = 1.00 | 1 | 0.00 → stop |
So 0.625₁₀ = 0.101₂. Verify: ✓
A fraction whose denominator is not a power of 2 never terminates — e.g. 0.1₁₀ = 0.0001100110011…₂. This is exactly why 0.1 + 0.2 is not exactly 0.3 in floating-point arithmetic.
4. Whole Number with a Fraction
Convert the two parts separately and join them: 45.625₁₀ = 101101.101₂
5. Quick Method for Small Integers — 8-4-2-1 Weights
Subtract the largest power of 2 that fits, repeatedly, and put a 1 in the corresponding position:
| Weight | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| Bit | 1 | 0 | 0 | 1 | 1 | 0 | 1 |
6. Range and Precision Points
- bits give patterns: unsigned range to (8 bits → 0-255; 16 bits → 0-65535).
- Each extra fractional bit halves the resolution (): 8 fractional bits give a resolution of .
- Conversion errors come only from the fractional part (truncation) — integer conversions are always exact.
7. Practice Numericals
| Problem | Answer |
|---|---|
| (156)₁₀ → binary | 10011100 |
| (1000)₁₀ → binary | 1111101000 |
| (1101011)₂ → decimal | 107 |
| (0.40625)₁₀ → binary | 0.01101 |
| (25.75)₁₀ → binary | 11001.11 |
| (11111111)₂ → decimal | 255 (= 2⁸ − 1) |
8. Exam Points
- Convert a given decimal integer and fraction to binary (show the table) — 5 marks, almost certain.
- Convert a binary number to decimal by positional expansion — 3 marks.
- With a worked example, explain why 0.1 cannot be represented exactly — 3-5 marks.
- Find the range of numbers representable in n bits (unsigned) — 3 marks.
- State the number of bits required for a given range of values — 2-3 marks.