CS Fundamentals
Master binary arithmetic — addition, subtraction using complements, multiplication, and overflow detection in binary calculations.
Introduction
If computers think in binary — only 0s and 1s — how do they perform calculations? How does a machine limited to two digits add, subtract, or multiply numbers? Binary arithmetic is the answer, and it is simpler than you might expect. The same principles you learned for decimal arithmetic (carrying, borrowing) apply to binary — just with a much smaller set of digits.
Understanding binary arithmetic is essential because it is literally how your computer's processor works at the lowest level. Every calculation your computer performs — from adding numbers in a spreadsheet to rendering 3D graphics — ultimately happens as binary arithmetic operations in the ALU (Arithmetic Logic Unit).
Binary Addition
Binary addition follows the same rules as decimal addition, with four basic cases: 0+0=0, 0+1=1, 1+0=1, and 1+1=10 (zero, carry 1 — just like 5+5=10 in decimal, you write 0 and carry 1). There is one more case when a carry is involved: 1+1+1=11 (one, carry 1).
Example: Add 1011 (11 decimal) + 1101 (13 decimal).
Working from right to left: Column 1: 1+1=10, write 0 carry 1. Column 2: 1+0+carry 1=10, write 0 carry 1. Column 3: 0+1+carry 1=10, write 0 carry 1. Column 4: 1+1+carry 1=11, write 1 carry 1. Final carry: write 1.
Result: 11000 (24 decimal). Verification: 11+13=24. Correct!
Binary Subtraction
Direct binary subtraction uses borrowing (like decimal subtraction). The cases are: 0-0=0, 1-0=1, 1-1=0, and 0-1=1 with a borrow from the next column (borrowing 1 from the next column gives you 10 in the current column — value 2 — then 10-1=1).
However, computers typically do not subtract directly. Instead, they use a technique called complement arithmetic that converts subtraction into addition (because addition circuits are simpler and faster). This uses the concept of complements.
One's Complement and Two's Complement
The one's complement of a binary number is obtained by flipping all bits: 0s become 1s and 1s become 0s. For example, the one's complement of 1011 is 0100.
The two's complement is obtained by taking the one's complement and adding 1. For example: two's complement of 1011 = 0100 + 1 = 0101.
Two's complement is how modern computers represent negative numbers. In an 8-bit system, positive 5 is 00000101. Negative 5 (-5) is the two's complement: flip bits to get 11111010, add 1 to get 11111011.
To subtract A - B, the computer calculates A + (two's complement of B). This converts every subtraction into an addition, simplifying the hardware — the ALU only needs an addition circuit.
Example: Calculate 7 - 3 using two's complement (4-bit numbers). 7 = 0111. 3 = 0011, two's complement of 3 = 1100 + 1 = 1101. Add: 0111 + 1101 = 10100. Discard the carry (overflow bit): 0100 = 4. So 7-3=4. Correct!
Binary Multiplication
Binary multiplication is simpler than decimal multiplication because you only multiply by 0 or 1. Multiplying by 0 gives 0, and multiplying by 1 gives the number itself. You create partial products and add them (shifting left for each subsequent bit).
Example: Multiply 101 (5) × 011 (3). Partial product 1: 101 × 1 = 101. Partial product 2: 101 × 1, shifted left = 1010. Partial product 3: 101 × 0, shifted left = 00000. Add partial products: 101 + 1010 = 1111 = 15 decimal. Verification: 5×3=15. Correct!
Overflow
Overflow occurs when the result of an arithmetic operation exceeds the number of bits available to represent it. In a 4-bit system, the maximum unsigned value is 1111 (15). If you add 1000 (8) + 1001 (9), the result is 10001 (17) — which requires 5 bits. The extra bit is lost, and the stored result (0001 = 1) is wrong.
Detecting and handling overflow is important in programming — it can cause bugs if not considered. Many programming languages provide ways to check for overflow conditions.
Key Takeaways
- Binary arithmetic uses the same principles as decimal — carrying and borrowing — with just two digits
- Addition: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (carry the 1)
- Computers use two's complement to represent negative numbers and perform subtraction as addition
- Two's complement: flip all bits, then add 1 — this converts subtraction into addition
- Binary multiplication is simpler than decimal — only multiply by 0 or 1
- Overflow occurs when results exceed available bit width — an important consideration in programming
- Practice these operations by hand — they appear frequently in exams
- Understanding binary arithmetic reveals how processors actually perform calculations at the hardware level
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Binary Arithmetic — Computer Fundamentals.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Computer Fundamentals topic.
Search Terms
computer-fundamentals, computer fundamentals, computer, fundamentals, data, representation, binary, arithmetic
Related Computer Fundamentals Topics