Two's Complement Arithmetic Operations
What you'll learn: How two's complement lets hardware perform addition and subtraction using the same circuitry for both signed and negative numbers—no special cases needed.
The Beautiful Trick
Two's complement isn't just a way to represent negative numbers—it's a representation designed so that addition and subtraction work exactly the same way whether you're dealing with positive or negative values. You don't need separate logic to check "Is this negative?" before doing math. The hardware just adds bits, and the answer comes out correct.
Addition: It Just Works
When you add two two's complement numbers, you add them bit-by-bit from right to left (with carries), exactly like unsigned addition. Any carry-out from the leftmost bit? Ignore it. The answer automatically wraps around correctly.
Example (4-bit): 5 + (-3) = 2
0101 (5)
+ 1101 (-3 in two's complement)
------
10010 → discard leftmost carry → 0010 (2)
The hardware doesn't "know" one number is negative—it just adds.
Subtraction: Convert to Addition
To compute A - B, the hardware converts it to A + (-B). How do you get -B? Flip all bits of B and add 1 (that's the two's complement negation you learned). Then perform regular addition.
This means one adder circuit handles both operations.
Why This Matters
Think of a clock: going forward 10 hours or backward 2 hours lands you at the same time. Two's complement creates a similar circular number system where adding a negative is indistinguishable from subtracting a positive—the hardware sees no difference.
Key Takeaway: Two's complement arithmetic uses simple binary addition for both positive and negative numbers without special sign-handling logic, making hardware implementation efficient and uniform.