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.
- 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?
- 1100: 6 + 6 = 12, which is 1100.
Binary addition and shifts: exam-style questions and mark schemes
What is the result of shifting 0001 0100 two places to the left? [1 mark]
Answer: 0101 0000
Add the binary numbers 0101 1010 and 0011 0111. Give your answer as an 8-bit binary number. [2 marks]
- Correct carries shown (1)
- 1001 0001 (1)
Explain what is meant by overflow, using 8-bit binary addition as an example. [2 marks]
- Overflow is when the result of a calculation is too big for the number of bits available (1)
- E.g. two 8-bit numbers that add up to more than 255 need a 9th bit, which is lost (1)
The binary number 0010 1000 is shifted two places to the right. Give the result in binary, and state the effect on its denary value. [2 marks]
- 0000 1010 (1)
- The value is divided by 4, from 40 to 10 (1)
Add the 8-bit binary numbers 10110110 and 01101101. Explain the problem with the result, and describe the effect of a 2-place left shift on 00010110. [6 marks]
- the sum is 100100011 (291 in denary) (1)
- an 8-bit register can only hold 00100011 (35) (1)
- this is an overflow error: the result is bigger than 255, so it needs 9 bits (1)
- the extra bit is lost, so the stored answer is wrong (1)
- 00010110 (22) shifted left 2 places gives 01011000 (88) (1)
- each left shift multiplies by 2, so 2 places multiplies by 4 (1)
- zeros fill the empty places on the right, and bits shifted off the left are lost (1)
How to answer them: exam technique and command words.
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.