Logical binary shifts Cambridge IGCSE Computer Science (9–1) revision

Not started

Learn it

In plain words

A logical shift slides every bit in a register a number of places to the left or to the right. Bits that fall off the end are lost, and zeros are fed in at the other end.

Because each place in binary is worth double the one to its right, shifting is a fast way to multiply or divide by 2.

5 things to know

  1. A shift left by one place multiplies the number by 2. Two places multiply it by 4, three places by 8.
  2. A shift right by one place divides the number by 2. Two places divide it by 4, three places by 8.
  3. Bits shifted out of the register are lost. Zeros fill the empty places at the opposite end.
  4. If a 1 is shifted out at the left (the most significant bit), the result is no longer the correct multiple.
  5. If a 1 is shifted out at the right (the least significant bit), the result is rounded down: the remainder is lost.

Worked example

Perform a logical left shift of two places on 00010110, and state the effect.

  1. Move every bit two places to the left. The two leftmost bits (both 0) drop off.
  2. Fill the two empty places on the right with zeros: 01011000.
  3. The value has been multiplied by 4: 22 has become 88.

Worked example

The number 00000111 is shifted one place to the right. Why is the result not exactly half?

  1. The result is 00000011, which is 3.
  2. Half of 7 is 3.5. The 1 that was shifted out was the bit worth 1, and it has been lost.
  3. So the answer is rounded down to 3.

Tips and tricks

  • State the effect as a number: "multiplied by 8", not just "it gets bigger".
  • Always count the bits in your answer. A shift never changes the length of the register.
5 questions, about 2 minutes.

It lands in your notebook with its questions as flashcards.

Logical binary shifts: 5 questions and answers

These are the quiz’s questions. Do the quiz first, then come back here for the ones that got you.

  1. What is 00001100 after a logical shift of two places to the left?
    • 00000011
    • 00011000
    • 00110000 (the answer)
    • 11000000

    Each bit moves two places left, and two zeros come in on the right. 12 becomes 48.

  2. A logical shift of three places to the left multiplies a number by:
    • 3
    • 6
    • 8 (the answer)
    • 9

    2 × 2 × 2 = 8.

  3. What is 01100000 after a logical shift of four places to the right?
    • 00000110 (the answer)
    • 00001100
    • 00000011
    • 01100000

    96 ÷ 16 = 6.

  4. What happens to bits that are shifted out of the end of a register?
    • They move round to the other end.
    • They are lost. (the answer)
    • They are stored in the next register.
    • They become 1s.

    They are lost, and zeros are shifted in at the opposite end.

  5. The 8-bit number 10100000 is shifted one place to the left. What is the result, and what has gone wrong?Stretch
    • 01010000: nothing has gone wrong
    • 01000000: a 1 has been lost, so the value is not doubled (the answer)
    • 11000000: the value has been doubled
    • 10100000: the bits do not move

    The leading 1 falls off the end. 160 doubled is 320, which cannot fit in 8 bits.

Still stuck on this one?Ask in the Papermunch Discord, or help someone else who is. Discord is for ages 13 and up.Join the server

Things you can type

Or go straight to

Or browse a shelf