Doing Sums in Binary
Computers add binary numbers using carry rules where (which is carry ). Adding yields : the rightmost makes carry , the middle column becomes carry , and the final column takes the carry.
Because a register holds a fixed width, any sum requiring extra bits suffers from overflow: the high bit is lost. In an 8-bit register, wraps to . This hardware behavior is entirely silent; software must account for it explicitly.
Signed Numbers and Two's Complement
Negative values use two's complement, where you invert all bits and add 1. The leftmost bit is the sign bit ( for positive, for negative). This lets the standard adder handle subtraction natively.
| 8-bit pattern | Value |
|---|---|
Pitfall: Assuming integers grow infinitely. Machine limits mean signed wraps silently to . Always watch your fixed widths!