UpperGrades

Binary shifts

AQA GCSE Computer Science (8525), specification 3.3.4 Binary arithmetic

A binary shift moves every bit in a binary number left or right by a number of places. AQA GCSE Computer Science only asks about logical shifts: bits that move off the end are lost, and the empty places are filled with 0s.

What you need to know

  • Apply a logical shift, left or right, to an 8-bit binary number.
  • A left shift of n places multiplies the value by 2ⁿ — 1 place doubles it, 2 places multiplies by 4, 3 places by 8 — as long as no 1s fall off the left-hand end.
  • A right shift of n places divides the value by 2ⁿ. Any 1s that fall off the right-hand end are lost, so the result is rounded down.
  • Describe where shifts are used: multiplying or dividing by a power of 2 quickly, because a shift is faster for the processor than repeated addition or subtraction.

What you don’t need

  • Arithmetic shifts and rotates — AQA only expects logical shifts.
  • Negative numbers: GCSE shift questions use unsigned 8-bit numbers.

Worked examples

  1. Apply a logical left shift of 1 place to the 8-bit binary number 1100 0000.

    1. Move every bit one place to the left.
    2. The leftmost 1 falls off the end and is lost. A 0 fills the empty place on the right.

    Answer: 1000 0000 — not 1000 0001: the lost bit doesn't wrap round to the other end.

  2. Apply a logical left shift of 2 places to 0000 0110. Give the result in binary and in denary.

    1. Move every bit two places to the left, and fill the two empty places on the right with 0s.
    2. 0000 0110 is 6. A 2-place left shift multiplies by 2² = 4, so expect 24.

    Answer: 0001 1000, which is 16 + 8 = 24

  3. Apply a logical right shift of 2 places to 0101 0000. Give the result in binary and in denary.

    1. Move every bit two places to the right, and fill the two empty places on the left with 0s.
    2. 0101 0000 is 80. A 2-place right shift divides by 4, so expect 20.

    Answer: 0001 0100, which is 16 + 4 = 20

Common mistakes

  • Wrapping the lost bit round to the other end. That's a rotate, not a shift: the bit is gone, and the gap is filled with 0.
  • Multiplying by 2 whatever the number of places. A 2-place left shift multiplies by 4, and a 3-place shift by 8.
  • Mixing up the directions: a left shift multiplies, a right shift divides.
  • Forgetting that 1s can fall off the end. When they do, the result is no longer exactly ×2ⁿ or ÷2ⁿ — 1100 0000 (192) shifted left 1 place is 1000 0000 (128), not 384.

Practise it

Learn it

Not a subscriber? Watch a sample lesson or see pricing.

Revise next

Written to the published AQA specification. UpperGrades isn’t affiliated with or endorsed by AQA.