Data Representation (8hrs) · Computer Fundamentals & Emerging Technologies

Binary arithmetic (addition, subtraction)

Watch lectures

Binary arithmetic (addition, subtraction)

1. Rules of Binary Addition

Only four basic cases plus one carry case:

A B Carry-in Sum Carry-out
0 0 0 0 0
0 1 0 1 0
1 0 0 1 0
1 1 0 0 1
1 1 1 1 1

In words: 0+0=00+0=0, 0+1=10+1=1, 1+0=11+0=1, 1+1=101+1=10 (sum 0, carry 1), 1+1+1=111+1+1=11 (sum 1, carry 1). Every column also adds the carry from the previous (right) column.

2. Multi-bit Addition Example: 1011₂ + 0110₂

   carry →   1 1 1 0
             1 0 1 1        (11)
           + 0 1 1 0        ( 6)
           ─────────
           1 0 0 0 1        (17)

Column by column (right to left): 1+0=11+0=1; 1+1=101+1=10 → write 0 carry 1; 1+0+1=101+0+1=10 → write 0 carry 1; 0+1+1=100+1+1=10 → write 0 carry 1; the final carry 1 becomes the new MSB. 1011 + 0110 = 10001₂ = 17₁₀ ✓

3. Rules of Binary Subtraction

A B Borrow Difference
0 0 0 0
1 0 0 1
1 1 0 0
0 1 1 1

0−0=00-0=0, 1−0=11-0=1, 1−1=01-1=0, 0−1=10-1=1 with a borrow of 1 taken from the next higher column (the borrowed 1 is worth 2 in the current column, hence 10−1=110-1=1).

4. Multi-bit Subtraction Examples

   1011 − 0110 = ?
   borrow →  1
             1 0 1 1        (11)
           − 0 1 1 0        ( 6)
           ─────────
             0 1 0 1        ( 5)   ✓

   1000 − 0011 = ?
   borrow → 1 1 1
             1 0 0 0        ( 8)
           − 0 0 1 1        ( 3)
           ─────────
             0 1 0 1        ( 5)   ✓

5. Subtraction using Complements (the hardware method)

Digital circuits build adders far more easily than subtractors, so subtraction is performed as an addition of the complement: A − B = A + (2's complement of B).

Example 1 (positive result): 9 − 6 in 4 bits

  9        = 1001
  6        = 0110   → 1's comp = 1001  → 2's comp = 1010
  1001 + 1010 = 1 0011 → discard the end-around carry → 0011 = +3   ✓

Example 2 (negative result): 6 − 9 in 4 bits

  6        = 0110
  9        = 1001   → 1's comp = 0110 → 2's comp = 0111
  0110 + 0111 = 1101 → NO carry out, so the result is negative;
  2's complement of 1101 = 0011 → answer = −3   ✓

Rule: carry out → result positive (discard the carry); no carry → result negative (take the 2's complement and prefix a minus sign).

6. Overflow in Signed Arithmetic

Overflow occurs when the true sum does not fit in the available bits, and it is detected by comparing the carry into and out of the MSB: different carries ⇒ overflow.

Example (4-bit signed, range −8 to +7): 5+55 + 5:

  0101 + 0101 = 1010  → 1010 is −6 in 2's complement, but 5+5=+10 → OVERFLOW

Valid signed range for nn bits:

−2n−1≤result≤2n−1−1-2^{n-1} ≤ result ≤ 2^{n-1} - 1

(4 bits: −8…+7; 8 bits: −128…+127). Adding two numbers of opposite signs can never overflow.

7. Related Operations

  • Multiplication follows 0×0=00×0=0, 0×1=00×1=0, 1×1=11×1=1; the partial products are just shifts, e.g. 101×011=1111101 × 011 = 1111.
  • Left shift by 1 = × 2, right shift by 1 = ÷ 2 (integer division) — much faster than multiply/divide circuits.
  • Binary addition is implemented by a half adder (XOR + AND) and a full adder (two half adders + OR); an n-bit ripple-carry adder chains n full adders.

8. Practice Numericals

Problem Answer
1110 + 1011 1 1001 (29)
11001 − 1011 1110 (14)
1010 − 1101 (4-bit, complement method) 1101 → −3
0111 + 0111 (4-bit signed) overflow — result −2 is wrong; true value +14

9. Exam Points

  • State the rules of binary addition and subtraction; solve two multi-bit examples — 5 marks, almost certain.
  • Perform subtraction using 1's/2's complement, showing the end-carry handling — 5 marks, very frequent.
  • What is overflow? How is it detected? Show with an example — 5 marks.
  • Prove that left shift = multiply by 2 and right shift = divide by 2 — 3 marks.
  • Find the signed range for n bits and check whether a given addition overflows — 3-5 marks.
Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.

← All Computer Fundamentals & Emerging Technologies modules