Understanding Binary Addition and Subtraction

Jul 16, 2024

Binary Addition and Subtraction

Introduction

  • Overview of binary addition and subtraction with examples.
  • Aim: Explain clearly so no doubts remain.

Binary Addition

Basic Rules

  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 0 = 1
  • 1 + 1 = 10 (2 in decimal)
    • Result: 0 (place value), Carry: 1
  • Example: 1 + 1 + 1
    • 1 + 1 = 10 (carry 1)
    • 10 (carry 1) + 1 = 11 (3 in decimal)

Examples

Simple Addition

  • 0 + 0 = 0
  • 1 + 0 = 1
  • 1 + 1 = 10 (carry 1)

Multiple Bits Addition

  • Example: 1110 (14 in decimal) + 1100 (12 in decimal)
    • Steps: Breakdown each bit, apply basic rules, and sum up.
    • Result: 11010 (26 in decimal)

Fractional Binary Numbers

  • Start from the rightmost bit (LSB).
  • Carry forward as needed.
  • Example conversion: 0.1110 + 0.1100
    • Decimal equivalent involves powers of 2: 0.75 and 0.375 respectively.
    • Sum: 1.125

Binary Subtraction

Basic Rules

  • 0 - 0 = 0
  • 1 - 0 = 1
  • 1 - 1 = 0
  • 0 - 1 requires borrowing:
    • Borrow '1' from the next higher bit.
    • Subtraction then follows normal rules.

Examples

Simple Subtraction

  • 0 - 0 = 0
  • 1 - 0 = 1
  • 1 - 1 = 0
  • 0 - 1 requires borrowing:
    • Example conversion: Borrow from the higher bit.

Multiple Bits Subtraction

  • Example: 1110 (14 in decimal) - 1010 (5 in decimal)
    • Steps: Breakdown each bit, borrow where needed, and subtract.
    • Result: 1001 (9 in decimal)

Complex Scenarios

  • Involves multiple borrow operations.
  • Example: larger binary numbers with multiple carry-overs.

Summary of Borrowing

  • Sequential borrowing if immediate higher bit is 0.