Cambridge IGCSE · Topic 1.1
IGCSE Computer Science 0478 / Topic 1 / IGCSE

Slide the bits.

Moving every bit one place to the left doubles a binary number; moving it one place to the right halves it. Processors use shifts as a very fast way to multiply and divide, but bits that fall off the end of the register are gone for good.

The key idea

A logical shift moves every bit in a register left or right by a number of places. Bits shifted off the end of the register are lost and zeros are shifted in at the opposite end. A left shift of n places multiplies a positive integer by 2n; a right shift of n places divides it by 2n. If a 1 is lost, the answer is no longer correct: the most significant bits are lost in a left shift, the least significant bits in a right shift.

logical left shift by 2 places 0001 0110 0101 1000 lost← 0s in← 22× 4 00010110 (22) becomes 01011000 (88)
Fig. 1: a left shift of 2 places multiplies 22 by 4; two 0s are lost on the left and two 0s enter on the right
Section 01

Shifting left.

In the lab, choose a number and press the left shift button. Each press moves every bit one place left and fills the right-hand end with 0.

Left shiftEffect on a positive integer
1 place× 2
2 places× 4
3 places× 8
n places× 2n
Worked example Left shift 3 places
Perform a logical left shift of 3 places on 00001101. Give the result and its effect.
  1. Move every bit 3 places left: the three leading 0s are lost.
  2. Fill the 3 empty places on the right with 0: 01101000.
  3. 00001101 = 13 and 01101000 = 64 + 32 + 8 = 104 = 13 × 8.
Answer: 01101000: the number has been multiplied by 8
Examiner trap

Always give 8 bits after a shift. Writing 1101000 instead of 01101000 shows you have not kept the register size.

Section 02

Shifting right.

Now press the right shift button. The bits move towards the 1s column, 0s enter on the left, and the rightmost bits fall off.

Worked example Right shift 3 places
Perform a logical right shift of 3 places on 10110000.
  1. Move every bit 3 places right: the three 0s on the right are lost.
  2. Fill the 3 empty places on the left with 0: 00010110.
  3. 10110000 = 176 and 00010110 = 22 = 176 ÷ 8.
Answer: 00010110: the number has been divided by 8
Worked example A 1 is lost
Perform a logical right shift of 1 place on 00010111 (23).
  1. The rightmost 1 is shifted out and lost.
  2. Result 00001011 = 11.
  3. 23 ÷ 2 = 11.5, but the half is lost, so the result is only the whole-number part.
Answer: 00001011 (11)
Your turn
Perform a logical right shift of 2 places on 01100100. Give the result in binary and denary.
Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

What is the effect of a logical left shift of 1 place on a positive integer (if no 1s are lost)?

Quick check+10 XP

What is the effect of a logical right shift of 2 places?

Quick check+10 XP

In a logical shift, what fills the empty places at the end of the register?

Quick check+10 XP

In the lab, what happens to a bit shifted past the end of the register?

Section 03

When shifts go wrong.

Shifting only multiplies or divides correctly while no 1s fall off the end. Try shifting 11000101 left in the lab and watch the value.

Examiner trap

"Shift left 2" means multiply by 4, not by 2. The factor is 2 to the power of the number of places.

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to IGCSE Paper 1 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

What is 00110100 after a logical right shift of 2 places?

Exam style+20 XP

What is 00000111 after a logical left shift of 4 places?

Exam style+20 XP

01100001 is shifted left 3 places. Why is the result not 97 × 8?

Exam style+20 XP

Which shift divides a positive 8-bit integer by 8?

Skill unlocked

Logical shifts, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
Logical left and right shifts on 8-bit integers, multiple shifts, lost bits, and the effect on the value.