🧮

Two's Complement Arithmetic

Sep 16, 2025

Overview

This lecture explains how to perform addition and subtraction using two's complement notation, including handling positive and negative binary numbers and interpreting results.

Two's Complement Addition for Positive Numbers

  • For positive numbers, use standard binary addition; no changes needed.
  • Example: 3 (0011) + 4 (0100) = 7 (0111).

Addition and Subtraction Involving Negative Numbers

  • To represent a negative number in two’s complement, invert all bits of the number and add one.
  • Example: To find -6 in four bits, take 6 (0110), flip bits (1001), add 1 → (1010).
  • Add positive and negative binary numbers directly, then interpret the result.

Interpreting the Result

  • If the most significant bit (MSB) of the result is 0, the answer is positive; keep the binary value as is.
  • If the MSB is 1, it’s negative; to find the decimal value, flip all bits and add one.
  • Ignore any carry out beyond the number of bits used.

Example Calculations

  • +5 (0101) + (-6) (1010) = (1111), MSB is 1 → flip bits (0000), add 1 → (0001) = -1.
  • -5 (1011) + 6 (0110) = (0001), MSB is 0 → answer is +1.
  • 23 (010111) - 6 (111010): After aligning bit widths and addition, ignore carry out; positive result with MSB 0.

Key Terms & Definitions

  • Two’s Complement — A method to represent negative numbers in binary by inverting bits and adding one.
  • MSB (Most Significant Bit) — The leftmost bit in a binary number; indicates sign (0 for positive, 1 for negative).
  • Carry Out — Any extra bit produced after the final addition; ignored in two’s complement.

Action Items / Next Steps

  • Practice converting positive integers to two’s complement negative form.
  • Complete assigned homework problems on two’s complement addition and subtraction.