Binary Arithmetic and Shifts
Adding binary
Work right to left, carrying when a column reaches 2:
0 + 0 = 0
0 + 1 = 1
1 + 1 = 10 (write 0, carry 1)
1 + 1 + 1 = 11 (write 1, carry 1)
Example: 0101 + 0011 = 1000 (5 + 3 = 8).
Overflow
If the result needs more bits than available (e.g. an 8-bit answer exceeds 255), the final carry is lost — an overflow error. The stored answer is wrong.
Binary shifts
- Left shift by n = multiply by 2ⁿ.
- Right shift by n = divide by 2ⁿ.
0000 0110 (6) left-shift 1 → 0000 1100 (12) ×2
0000 0110 (6) right-shift 1 → 0000 0011 (3) ÷2
Bits shifted off the end are lost, which can lose precision.
Exam tip
State clearly whether a shift multiplies or divides and by what factor (2ⁿ). Mention that data can be lost off the end.