Binary Arithmetic and Complements: Addition to 2's
Computers do all their arithmetic, from adding a bill to rendering games, with only the digits 0 and 1. Binary arithmetic follows the same ideas as school decimal arithmetic but with simpler rules, since 1 + 1 is the biggest sum you ever handle. These rules show exactly how a CPU's arithmetic unit works.
Negative numbers are the tricky part. Instead of a minus sign, computers use complements. The 2's complement is brilliant: it lets the CPU subtract using the same addition circuit, with no separate subtractor. Every negative integer in your computer is stored this way.
Key Concepts
- Binary addition: 0+0=0, 0+1=1, 1+1=10 (write 0, carry 1), 1+1+1=11 (write 1, carry 1).
- Binary multiplication: shift-and-add, like decimal long multiplication with simpler digits.
- 1's complement: flip every bit; 1001 becomes 0110.
- 2's complement: 1's complement plus 1; 1001 becomes 0111. This represents the negative of the number.
- Subtraction by addition: A − B = A + (2's complement of B); discard the final carry out.
- Signed range: n bits in 2's complement cover −2n−1 to +2n−1 − 1; eight bits give −128 to +127.
- Overflow: a result needing more bits than available loses the extra bit and comes out wrong.
Formulas
- 2's complement: negative(B) = (bitwise NOT of B) + 1, within a fixed bit width.
- Subtraction: A − B = A + 2's complement(B), discarding carry beyond n bits.
- Sign bit: the leftmost bit: 0 means zero or positive, 1 means negative.
Worked Example
Compute 13 − 9 using 4-bit 2's complement.
- 13 = 1101, 9 = 1001. 2's complement of 1001: flip to 0110, add 1 to get 0111.
- Add: 1101 + 0111 = 10100. Discard the final carry: 0100.
- 0100 is 4, and 13 − 9 = 4. The CPU never needed a subtraction circuit.
Common Misconceptions
- The discarded carry means an error. It is a normal part of the method; in 2's complement subtraction the carry out is always thrown away.
- 1's and 2's complement are interchangeable. They are not: 1's complement has two zeros and needs correction, while 2's complement has one zero and plain addition just works.
- CPUs borrow like school subtraction. They convert subtraction into complement addition because one adder circuit is cheaper and faster than two circuits.
Real-World Applications
- Every CPU ALU adds, subtracts, and compares using 2's complement.
- Audio and video DSP chips do millions of complement operations per second.
- Network checksums rely on binary addition with discarded carries.
- Microcontroller firmware uses these methods for multi-byte arithmetic.
To recap: binary arithmetic uses tiny rule sets, and the 2's complement turns subtraction into addition so one circuit does both. Flip the bits, add one, add, discard the carry: that recipe is literally how your processor subtracts.
Related blogs
- Number Systems: Binary Octal Hexadecimal Easy Explanation
- Boolean algebra and De Morgan's theorems Explained with
- Logic Gates and Universal Gates Explained in Simple Words
- Combinational Circuits: Adders, Multiplexers And More
- Sequential Circuits: SR, JK, D and T Flip-Flops Explained
- Counters and Shift Registers: Working and Types Explained