AQA 8525 GCSE Computer Science · 3.3 Fundamentals of Data Representation

Stretch tasks Binary Arithmetic and Shifts

Task 1

Quiz Challenge

A quiz game against four computer players, then short and long written answers.

  1. Quiz Blitz12 questions against the clock
  2. Quick Fire4 short answers
  3. Big Think2 long answers

About 20 minutes

Task 2

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

Task 3

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

Task 4

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

  1. What is 01101101 + 00110110? Give 8 bits.

  2. In binary addition, what is 1 + 1?

    • 1 carry 1
    • 0 carry 1
    • 2
    • 1 carry 0
  3. What does 1 + 1 + 1 give in one column?

    • 0 carry 1
    • 11 carry 0
    • 3
    • 1 carry 1
  4. Overflow usually makes a program crash.

    • True
    • False
  5. 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
  6. Shift 00001011 left by 1 place. Give the 8-bit result.

  7. Shift 00011001 right by 1 place. Give the 8-bit result.

  8. A left shift by 3 places multiplies by...

    • 8
    • 3
    • 6
    • 9
  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
  10. AQA expects you to be able to add up to three binary numbers.

    • True
    • False
  11. Which column does a binary addition start from?

    • Either end
    • The rightmost column
    • The leftmost column
    • The middle
  12. A right shift of an odd number loses...

    • Its sign
    • Every bit
    • Nothing
    • Its remainder

Quiz Challenge, round 2: Quick Fire

  1. Define overflow, and explain why it is dangerous. [2 marks]

  2. Explain what happens to the bits when 00011001 is shifted right by 1 place. [2 marks]

  3. Explain why a left shift is used to multiply a number by 4. [2 marks]

  4. Add 01010101 and 00110011, then add 00000111 to the result. Give each 8-bit answer. [2 marks]

Quiz Challenge, round 3: Big Think

  1. 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]

  2. Add 11000000 and 10000000 in an 8-bit register. Explain the result. [4 marks]

This or That: tick the right answer

  1. Is there a digit 2 in binary?

    • No: 1 + 1 is 0 carry 1
    • Yes: 1 + 1 is 2
  2. What comes in on the right during a left shift?

    • Zeros
    • Ones
  3. 00000110 is shifted left by 1. What is its value?

    • 3
    • 12
  4. 00000110 is shifted right by 1. What is its value?

    • 3
    • 12
  5. Which bit has the largest place value?

    • The most significant bit
    • The least significant bit
  6. Why write the carry row in a binary addition?

    • It earns method marks
    • It speeds up the CPU
  7. Bits shifted off the end of a register...

    • Are discarded
    • Wrap round to the other end
  8. 25 shifted right by 1 gives...

    • 12.5
    • 12

Memory Match: match each operation to its result

OperationResult
A 0 + 01 0 carry 1
B 1 + 02 0
C 1 + 13 1
D 1 + 1 + 14 Multiply by 2
E Left shift by 15 Divide by 2, losing any remainder
F Right shift by 16 1 carry 1

Sort It: tick one box in each row

Left shift, right shift or overflow?

StatementLeft shiftRight shiftOverflow
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

  1. 10100011 109 + 54 = 163, which is 10100011.
  2. 0 carry 1 There is no digit 2 in binary.
  3. 1 carry 1 Three is 11 in binary: write 1 and carry 1.
  4. False It usually stores a wrong value with no error reported, which is what makes it dangerous.
  5. 01000000, which is 64 192 + 128 = 320 needs nine bits, so the carry out is lost and 64 is stored.
  6. 00010110 11 becomes 22: a left shift doubles.
  7. 00001100 25 becomes 12: the 1 that falls off the right is the remainder, and it is lost.
  8. 8 2 x 2 x 2 = 8.
  9. A shift is a single, cheap hardware operation It does less work than a general multiply.
  10. True Adding the first two, then the third, is safe and fully acceptable.
  11. The rightmost column Exactly as in denary, from the least significant bit.
  12. 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 answer

    Overflow 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 answer

    Every 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 answer

    Shifting 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 answer

    01010101 + 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 answer

    A 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 answer

    Adding 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

  1. No: 1 + 1 is 0 carry 1 Binary only has 0 and 1.
  2. Zeros The empty places are always filled with 0.
  3. 12 6 doubled is 12.
  4. 3 6 halved is 3.
  5. The most significant bit The leftmost bit is the most significant.
  6. It earns method marks Examiners can only credit a method they can see.
  7. Are discarded They are gone, which is why shifts can lose information.
  8. 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

  1. Left shift 00001011 becomes 00010110 11 becomes 22.
  2. Right shift 00011001 becomes 00001100 25 becomes 12.
  3. Overflow 192 + 128 stored in 8 bits gives 64 320 needs nine bits, so the stored value is wrong.
  4. Right shift An odd number loses its remainder The bit that falls off the right is the remainder.
  5. Overflow A carry out of the most significant bit is lost There is no bit left to hold it.
  6. Left shift Zeros come in on the right A left shift fills the right-hand end with zeros.
  7. Right shift Divides by 2 for each place Moving bits right halves the value.
  8. Overflow A wrong value is stored with no error reported That is what makes overflow dangerous.
  9. Overflow The result needs more bits than the register has That is the definition of overflow.
  10. Right shift Zeros come in on the left A right shift fills the left-hand end with zeros.
  11. Left shift Multiplies by 2 for each place Moving bits left doubles the value.