Study Guide

Logical Binary Shifts

How sliding every bit of a binary number left or right multiplies or divides it by powers of two, what happens to the bits that fall off the end, and when the result is no longer exact.

Lesson 1.4 Data Representation

For: Cambridge IGCSE Computer Science learners, or anyone who can already convert between binary and denary

Stage: Think

Sliding digits along

Dev, a fictional pupil, writes numbers in a grid with a ones column and a tens column. He writes 35: a 3 in the tens column and a 5 in the ones column.

Think it through

Dev slides both digits one column to the left and writes a 0 in the empty ones column. What number does the grid show now, and how does it compare with 35?

Show what happens

The grid shows 350. The 3 is now in the hundreds column and the 5 in the tens column, so each digit is worth ten times as much, and the whole number is ten times as large.

Think it through

In binary every column is worth twice the one on its right. Predict: what happens to the value of a binary number if every bit slides one column to the left, with a 0 filling the gap? What would happen if every bit slid one column to the right instead?

Show what happens

Sliding left makes every bit worth twice as much, so the whole number doubles. Sliding right makes every bit worth half as much, so the whole number halves. The rest of the lesson tests this prediction and finds what happens at the edges of a register.

Stage: Discover

Shifting left

Computers do this inside an 8-bit register. Imagine the register as eight boxes in a row, each holding a bit. Everything is slid one box to the left.

Think it through

A register holds 0000 0101 (5 in denary). Slide every bit two places to the left, putting 0 into each gap on the right. What pattern does the register hold, and what is its value in denary?

Show a model answer

One slide gives 0000 1010 (10). A second slide gives 0001 0100, which is 16 + 4 = 20. That is 5 × 4: each slide doubled the value.

Sliding all the bits of a binary number along by a number of places is called a logical shift. In a logical left shift every bit moves one place to the left and a 0 is shifted in at the right-hand end. Moving by more than one place is a multiple shift: the same step, repeated.

Shifting 0000 1100 left, one place at a time

Each step shifts the register one more place to the left, with a 0 shifted in at the right. Watch the value as well as the pattern.

  1. Step 1 of 6: Start

    The register holds 0000 1100, which is 8 + 4 = 12.

  2. Step 2 of 6: Shift left once

    0001 1000, which is 16 + 8 = 24. The value has doubled.

  3. Step 3 of 6: Shift left twice

    0011 0000, which is 32 + 16 = 48. Doubled again.

  4. Step 4 of 6: Shift left three times

    0110 0000, which is 64 + 32 = 96. The total is 12 × 2 × 2 × 2 = 12 × 8.

  5. Step 5 of 6: Shift left four times

    1100 0000, which is 128 + 64 = 192. The leftmost 1 now sits in the 128s column, the leftmost column of the register.

  6. Step 6 of 6: Shift left five times

    1000 0000, which is 128. The leftmost 1 was shifted out of the register and lost, so the value did not double to 384: it could not be stored.

    Technical detail: The register has no ninth column, just as it had none when an addition overflowed.

Stage: Predict

Shifting right

Think it through

A register holds 0010 1000 (40 in denary). Predict the pattern and the value after one logical shift to the right, with a 0 shifted in at the left. Then predict what happens after six shifts.

Show a model answer

After one shift right the register holds 0001 0100, which is 16 + 4 = 20: half of 40. The table below continues the pattern for all six shifts.

In a logical right shift every bit moves one place to the right and a 0 is shifted in at the left-hand end.

Number of shifts rightPatternValueWhat fell off the right-hand end
00010 100040nothing yet
10001 0100200
20000 1010100
30000 010150
40000 001021
50000 000110
60000 000001

Check your understanding

A register holds 0000 1000 (8). It is shifted right by 2 places. What does it hold now?
Show the answer

Answer: A. 0000 0010, because the 1 moves two places right and 0s fill the gap.

The single 1 is in the 8s column. After one shift right it is in the 4s column, and after two it is in the 2s column: 0000 0010, which is 2.

Stage: Explain

The bits that fall off the end

Think it through

A register holds 1100 0000 (192). It is shifted left by one place. What happens to the leftmost 1, and does the register now hold 192 × 2?

Show what happens

The leftmost 1 is shifted out of the end of the register and lost. The register holds 1000 0000, which is 128. The true answer to 192 × 2 is 384, which is more than 255 and cannot be stored, so the result is no longer a doubling.

The bit at the left-hand end of a number, which is worth the most, is the most significant bit (MSB). The bit at the right-hand end, which is worth the least, is the least significant bit (LSB).

  • A left shift can lose the most significant bit or bits. Zeros are shifted in at the least significant end.
  • A right shift can lose the least significant bit or bits. Zeros are shifted in at the most significant end.

This gives the effect of a shift:

  • A left shift by n places multiplies by 2 n times: by 2 for one place, by 4 for two, by 8 for three. The result is exact only if the bits shifted out are all 0.
  • A right shift by n places divides by 2 n times and drops any remainder. The result is exact only if the bits shifted out are all 0. Otherwise it is the whole-number part: 13 shifted right once is 6, not 6.5.

A logical shift does not rotate the bits round. The bits that leave one end are lost, they do not come back in at the other end, and what comes in is always 0. (Shifts that treat bits differently, such as ones that wrap round, exist, but they are not logical shifts.)

Check your understanding

A register holds 0110 0001 (97). It is shifted left by 2 places. Which statement is correct?
Show the answer

Answer: B. It holds 1000 0100 (132), because a 1 was lost from the left end, so it is no longer 4 × 97.

Shifting 0110 0001 left once gives 1100 0010, and a second time gives 1000 0100. Two bits left the register, a 0 and then a 1, and the 1 was worth 256 in the true answer. 1000 0100 is 128 + 4 = 132.

Stage: Experiment

Shifting on your own

  1. Say what the shift does. A right shift by 3 places moves every bit three places to the right and shifts in three 0s at the left, so the value is divided by 2 three times, which is by 8.
  2. Check what will be lost. The three bits at the right-hand end are 0, 0 and 0, so nothing important falls off and the division is exact.
  3. Shift one place at a time. 1010 1000 becomes 0101 0100, then 0010 1010, then 0001 0101.
  4. Check in denary. 1010 1000 is 128 + 32 + 8 = 168, and 168 ÷ 8 = 21. 0001 0101 is 16 + 4 + 1 = 21.

Now try the first row, then the rest, shifting each register as stated.

Logical shifts of an 8-bit register
StartStart in denaryShiftResultResult in denary
0000 01106left by 10000 110012
0001 001119left by 2
1010 1000168right by 3
0000 111115right by 2
1100 0101197left by 1

    Show the completed table
    StartStart in denaryShiftResultResult in denary
    0000 01106left by 10000 110012
    0001 001119left by 20100 110076
    1010 1000168right by 30001 010121
    0000 111115right by 20000 00113
    1100 0101197left by 11000 1010138

    Check your understanding

    In the table, which shifts gave a result that was exactly the start value multiplied or divided, with no bits lost that were 1?
    Show the answer

    Answer: B. Left by 1 on 0000 0110, left by 2 on 0001 0011 and right by 3 on 1010 1000.

    Rows 1 to 3 lost only 0s. In row 4 (15 shifted right by 2) two 1s fell off the right end, and in row 5 (197 shifted left by 1) the leftmost 1 fell off the left end, so those results are not exact.

    Stage: Apply

    Use it somewhere new

    A fictional game keeps a character’s speed in an 8-bit register as 0001 0110 (22). A power-up shifts the register left by 2 places.

    Apply it

    What is the character’s speed after the power-up?
    Show the answer

    Answer: C. 88, because two shifts left multiply 22 by 4 and no 1 is lost.

    Two shifts left multiply by 2 × 2 = 4: 22 × 4 = 88. The leftmost bits of 0001 0110 are 0, so no 1 is lost and the result is exact.

    A fictional sensor doubles each reading by a single left shift of an 8-bit register.

    Apply it

    For which starting reading does the single left shift not give double the value?
    Show the answer

    Answer: D. 1000 0001, because the leftmost 1 is shifted out of the register and lost.

    Doubling a value gives the right answer only if the leftmost bit is 0, because then no 1 is shifted out. 1000 0001 is 129, and 129 × 2 = 258 does not fit in 8 bits: the register holds 0000 0010, which is 258 − 256 = 2.

    Apply it

    A register holds 0100 1001 (73). After one logical shift right it holds 0010 0100 (36). Why is it not 36.5?
    Show the answer

    Answer: B. The 1 shifted out at the right stood for the half, which cannot be stored.

    73 is odd, so its right-hand bit is 1. That bit was shifted out and lost, and with it the 0.5, leaving the whole-number part, 36.

    Apply it

    Tom says that shifting left by 3 places multiplies a number by 3. Sara says it multiplies it by 8. Which of them is right, and why?
    Show the answer

    Answer: A. Sara: each place doubles the value, so three places multiply by 8.

    Each shift left doubles the value, so n shifts multiply by 2 repeated n times, which is 2ⁿ: 2, 4, 8, 16 and so on. Three places multiply by 8.

    Stage: Consolidate

    Bring it together

    Think it through

    Without looking back, explain to a friend what a logical shift left by 2 places does to an 8-bit number, what is shifted in, and when the result is no longer 4 times the original.

    Show a model answer

    Every bit moves two places to the left, two 0s are shifted in at the right, and the number is multiplied by 4. If either of the two bits shifted out at the left end is a 1, those bits are lost and the register no longer holds 4 times the original, because the true answer would not fit in 8 bits.

    Check your understanding

    A register holds 0001 0110 (22) and is shifted right by 2 places. Which statement is correct?
    Show the answer

    Answer: C. The bits 1 and 0 at the right-hand end are lost, so 0000 0101 (5) is not exactly 22 ÷ 4.

    0001 0110 shifted right twice becomes 0000 0101. The two bits that left at the right-hand end were 1 and 0. 22 ÷ 4 = 5.5, and the register keeps 5.

    • A logical shift moves every bit of a binary number a set number of places left or right. Bits shifted off the end of the register are lost, and 0s are shifted in at the other end.
    • A left shift by n places multiplies by 2ⁿ. It can lose the most significant bit or bits, and the result is exact only if they are all 0.
    • A right shift by n places divides by 2ⁿ and drops the remainder. It can lose the least significant bit or bits, and the result is exact only if they are all 0.
    • Shifting by several places is the same one-place shift repeated, so the effect is multiplied or divided by 2 each time.
    • A logical shift does not wrap the lost bits round to the other end.

    Sources and scope

    • What this lesson is. The fourth lesson of the Data Representation module, written for this site. It teaches point 5 of Cambridge IGCSE Computer Science 1.1 (logical shifts of a positive 8-bit integer) against the 2026 to 2028 syllabus (version 6). Its curriculum links are provisional: no link has been verified by the site owner. They show where the lesson may help with a course and imply no review or endorsement by any examination board.
    • Original material. Dev and his place-value grid, the game character’s speed and the sensor readings are fictional examples written for this lesson.
    • Simplified on purpose. Only logical shifts of positive 8-bit integers are taught. Arithmetic shifts (which treat the left-hand bit as a sign) and cyclic shifts, which bring lost bits back round, are not covered. Real processors also report a lost bit in a flag, which this lesson does not describe.