Binary addition
- The rules: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1), and 1 + 1 + 1 = 11 (write 1, carry 1).
- Work from right to left, carrying just as in denary. 0101 1010 + 0011 0111 = 1001 0001, which is 90 + 55 = 145.
Overflow
- Overflow happens when a result is too big to fit in the number of bits available. In 8 bits, 200 + 100 = 300 needs 9 bits, so the extra bit is lost and the stored answer is wrong.
Binary shifts
- A logical shift left by n places multiplies the number by 2ⁿ. 0000 0110 (6) shifted left 2 places is 0001 1000 (24).
- A logical shift right by n places divides the number by 2ⁿ. 0001 1000 (24) shifted right 3 places is 0000 0011 (3).
- The gaps are filled with 0s, and bits shifted off the end are lost. So 0000 0111 (7) shifted right 1 place is 0000 0011 (3), not 3.5.
Key terms
- Carry
- A 1 moved to the next column when a column adds up to 2 or 3.
- Overflow
- When a result needs more bits than are available.
- Logical shift
- Moving all the bits left or right, filling the gaps with 0s.
- Shift left
- Moves the bits left: each place multiplies the number by 2.
- Shift right
- Moves the bits right: each place divides the number by 2.
Quick questions on Binary addition and shifts
- What is 1 + 1 in binary?
- 10: Write 0 and carry 1.
- What is 1 + 1 + 1 in binary?
- 11: 3 in denary is 11 in binary.
- What is 0011 + 0101 in binary?
- 1000: 3 + 5 = 8, which is 1000.
- What is overflow?
- When a result needs more bits than are available: The extra bit is lost, so the answer is wrong.
- What does a shift left by 1 place do to a binary number?
- Multiplies it by 2: Each place is worth twice as much.
- What does a shift right by 2 places do to a binary number?
- Divides it by 4: 2² = 4.
- What is 0000 0110 shifted left by 2 places?
- 0001 1000: 6 × 4 = 24.
- In 8 bits, what happens when you add 1111 1111 and 0000 0001?
- Overflow: the result needs 9 bits: 255 + 1 = 256, which needs 9 bits.
Binary addition and shifts: questions and answers
- What is 0000 0111 shifted right by 1 place?
- 0000 0011. The rightmost 1 is lost, so 7 becomes 3.
- Why can a right shift give an inaccurate result?
- Bits shifted off the end are lost. The remainder is lost.
- What is 0110 + 0110 in binary?
- 6 + 6 = 12, which is 1100.