AQA 8525 GCSE Computer Science · 3.3 Fundamentals of Data Representation
Stretch tasks Binary Arithmetic and Shifts
Quiz Challenge
A quiz game against four computer players, then short and long written answers.
- Quiz Blitz12 questions against the clock
- Quick Fire4 short answers
- Big Think2 long answers
About 20 minutes
This or That
Pixel the cat asks 8 questions. Each has two answers: pick the right one.
- Two answers to every question
- A fish treat for every right answer
- Streaks win Pixel shades, then a party hat
About 4 minutes
Memory Match
Flip the cards two at a time to match each operation card to its result card.
- 12 cards: each operation has a result
- One peek at every card
- Combo points for pairs found in a row
6 pairs, about 4 minutes
Sort It
Sort each statement into the right box, like the tick-box tables in the exam.
- 11 cards to sort into 3 boxes
- Drag a card, tap a box or press its number
- Combo points for cards sorted in a row
11 cards, about 4 minutes
The games need JavaScript. Every question is below, with the answers at the end.
Read the lesson: Binary Arithmetic and Shifts
Binary Arithmetic and Shifts: the questions
Quiz Challenge, round 1: Quiz Blitz
What is 01101101 + 00110110? Give 8 bits.
In binary addition, what is 1 + 1?
- 1 carry 1
- 0 carry 1
- 2
- 1 carry 0
What does 1 + 1 + 1 give in one column?
- 0 carry 1
- 11 carry 0
- 3
- 1 carry 1
Overflow usually makes a program crash.
- True
- False
11000000 + 10000000 is worked out in 8 bits. What value is stored?
- 101000000, which is 320
- 11111111, which is 255
- 00000000, which is 0
- 01000000, which is 64
Shift 00001011 left by 1 place. Give the 8-bit result.
Shift 00011001 right by 1 place. Give the 8-bit result.
A left shift by 3 places multiplies by...
- 8
- 3
- 6
- 9
Why do compilers replace multiplying by 8 with a shift?
- Shifts never overflow
- Multiplication is not allowed
- Shifts use less memory
- A shift is a single, cheap hardware operation
AQA expects you to be able to add up to three binary numbers.
- True
- False
Which column does a binary addition start from?
- Either end
- The rightmost column
- The leftmost column
- The middle
A right shift of an odd number loses...
- Its sign
- Every bit
- Nothing
- Its remainder
Quiz Challenge, round 2: Quick Fire
Define overflow, and explain why it is dangerous. [2 marks]
Explain what happens to the bits when 00011001 is shifted right by 1 place. [2 marks]
Explain why a left shift is used to multiply a number by 4. [2 marks]
Add 01010101 and 00110011, then add 00000111 to the result. Give each 8-bit answer. [2 marks]
Quiz Challenge, round 3: Big Think
Explain what a binary shift is, and the effect of left and right shifts, including what happens to bits that fall off the end. [6 marks]
Add 11000000 and 10000000 in an 8-bit register. Explain the result. [4 marks]
This or That: tick the right answer
Is there a digit 2 in binary?
- No: 1 + 1 is 0 carry 1
- Yes: 1 + 1 is 2
What comes in on the right during a left shift?
- Zeros
- Ones
00000110 is shifted left by 1. What is its value?
- 3
- 12
00000110 is shifted right by 1. What is its value?
- 3
- 12
Which bit has the largest place value?
- The most significant bit
- The least significant bit
Why write the carry row in a binary addition?
- It earns method marks
- It speeds up the CPU
Bits shifted off the end of a register...
- Are discarded
- Wrap round to the other end
25 shifted right by 1 gives...
- 12.5
- 12
Memory Match: match each operation to its result
| Operation | Result |
|---|---|
A 0 + 0 | 1 0 carry 1 |
B 1 + 0 | 2 0 |
C 1 + 1 | 3 1 |
D 1 + 1 + 1 | 4 Multiply by 2 |
| E Left shift by 1 | 5 Divide by 2, losing any remainder |
| F Right shift by 1 | 6 1 carry 1 |
Sort It: tick one box in each row
Left shift, right shift or overflow?
| Statement | Left shift | Right shift | Overflow |
|---|---|---|---|
| 00001011 becomes 00010110 | |||
| 00011001 becomes 00001100 | |||
| 192 + 128 stored in 8 bits gives 64 | |||
| An odd number loses its remainder | |||
| A carry out of the most significant bit is lost | |||
| Zeros come in on the right | |||
| Divides by 2 for each place | |||
| A wrong value is stored with no error reported | |||
| The result needs more bits than the register has | |||
| Zeros come in on the left | |||
| Multiplies by 2 for each place |
Answers
Round 1: Quiz Blitz
- 10100011 109 + 54 = 163, which is 10100011.
- 0 carry 1 There is no digit 2 in binary.
- 1 carry 1 Three is 11 in binary: write 1 and carry 1.
- False It usually stores a wrong value with no error reported, which is what makes it dangerous.
- 01000000, which is 64 192 + 128 = 320 needs nine bits, so the carry out is lost and 64 is stored.
- 00010110 11 becomes 22: a left shift doubles.
- 00001100 25 becomes 12: the 1 that falls off the right is the remainder, and it is lost.
- 8 2 x 2 x 2 = 8.
- A shift is a single, cheap hardware operation It does less work than a general multiply.
- True Adding the first two, then the third, is safe and fully acceptable.
- The rightmost column Exactly as in denary, from the least significant bit.
- Its remainder The bit that falls off the right is the remainder of the division by 2.
Round 2: Quick Fire
- The result needs more bits than are available, so a carry is lost
- A wrong value is stored and used, with no error reported
Model answerOverflow happens when the result of an addition needs more bits than are available, so the carry out of the most significant bit is lost. It is dangerous because a wrong value is stored and used, and usually no error is reported.
- Every bit moves one place right, and a zero comes in on the left
- The rightmost 1 is discarded, so 25 becomes 12
Model answerEvery bit moves one place to the right and a zero comes in on the left. The 1 on the right-hand end is discarded, so 25 becomes 12: the remainder is lost.
- Shifting left 2 places multiplies by 2 twice
- A shift is a single, fast hardware operation
Model answerShifting left 2 places multiplies by 2 twice, which is 4, and a shift is a single, fast hardware operation, far cheaper than a general multiply.
- 01010101 + 00110011 = 10001000
- 10001000 + 00000111 = 10001111
Model answer01010101 + 00110011 = 10001000. Then 10001000 + 00000111 = 10001111.
Round 3: Big Think
- Every bit moves a number of places
- A left shift multiplies by 2 for each place
- A right shift divides by 2 for each place
- Zeros come in at the other end
- Bits shifted out are discarded, not wrapped round
- A right shift loses the remainder, so precision is lost
- A left shift overflows if a 1 falls off the left
Model answerA binary shift moves every bit a number of places left or right. A left shift multiplies by 2 for each place, with zeros coming in on the right; a right shift divides by 2 for each place, with zeros coming in on the left. Bits shifted out of the end are discarded, not wrapped round. So a right shift of an odd number loses the remainder: 25 shifted right once gives 12, not 12.5, so precision is lost. And if a 1 falls off the left of a left shift, the answer is wrong: that is overflow.
- The full answer is 101000000
- That is 320
- It needs nine bits, so the carry out is lost: overflow
- 01000000, which is 64, is stored: a wrong value
Model answerAdding column by column from the right gives 101000000, which is 192 + 128 = 320. That needs nine bits, but the register only has eight, so the carry out of the most significant bit is lost: this is overflow. The value stored is 01000000, which is 64, a wrong answer, and no error is reported.
This or That
- No: 1 + 1 is 0 carry 1 Binary only has 0 and 1.
- Zeros The empty places are always filled with 0.
- 12 6 doubled is 12.
- 3 6 halved is 3.
- The most significant bit The leftmost bit is the most significant.
- It earns method marks Examiners can only credit a method they can see.
- Are discarded They are gone, which is why shifts can lose information.
- 12 There is nowhere to store the half.
Memory Match
- A 2
0 + 0: 0 - B 3
1 + 0: 1 - C 1
1 + 1: 0 carry 1 - D 6
1 + 1 + 1: 1 carry 1 - E 4 Left shift by 1: Multiply by 2
- F 5 Right shift by 1: Divide by 2, losing any remainder
Sort It
- Left shift 00001011 becomes 00010110 11 becomes 22.
- Right shift 00011001 becomes 00001100 25 becomes 12.
- Overflow 192 + 128 stored in 8 bits gives 64 320 needs nine bits, so the stored value is wrong.
- Right shift An odd number loses its remainder The bit that falls off the right is the remainder.
- Overflow A carry out of the most significant bit is lost There is no bit left to hold it.
- Left shift Zeros come in on the right A left shift fills the right-hand end with zeros.
- Right shift Divides by 2 for each place Moving bits right halves the value.
- Overflow A wrong value is stored with no error reported That is what makes overflow dangerous.
- Overflow The result needs more bits than the register has That is the definition of overflow.
- Right shift Zeros come in on the left A right shift fills the left-hand end with zeros.
- Left shift Multiplies by 2 for each place Moving bits left doubles the value.