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?
- Hint 1: Which column is the 3 in now? What is each unit of that column worth?
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?
- Hint 1: Compare with Dev’s grid: the columns there were worth ten times as much. What are the columns of a binary number worth?
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?
- Hint 1: Move one place at a time: first 0000 0101 slides to what, then what?
- Hint 2: Convert the final pattern with the columns 128, 64, 32, 16, 8, 4, 2 and 1.
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.
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.
Step 1 of 6: Start
The register holds 0000 1100, which is 8 + 4 = 12.
Step 2 of 6: Shift left once
0001 1000, which is 16 + 8 = 24. The value has doubled.
Step 3 of 6: Shift left twice
0011 0000, which is 32 + 16 = 48. Doubled again.
Step 4 of 6: Shift left three times
0110 0000, which is 64 + 32 = 96. The total is 12 × 2 × 2 × 2 = 12 × 8.
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.
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.
- Hint 1: Move every bit one place to the right. What is the new value of each bit’s column?
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 right | Pattern | Value | What fell off the right-hand end |
|---|---|---|---|
| 0 | 0010 1000 | 40 | nothing yet |
| 1 | 0001 0100 | 20 | 0 |
| 2 | 0000 1010 | 10 | 0 |
| 3 | 0000 0101 | 5 | 0 |
| 4 | 0000 0010 | 2 | 1 |
| 5 | 0000 0001 | 1 | 0 |
| 6 | 0000 0000 | 0 | 1 |
Check your understanding
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?
- Hint 1: The register has eight columns and no ninth one. Where could a ninth bit go?
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
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
- 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.
- 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.
- Shift one place at a time. 1010 1000 becomes 0101 0100, then 0010 1010, then 0001 0101.
- 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.
| Start | Start in denary | Shift | Result | Result in denary |
|---|---|---|---|---|
| 0000 0110 | 6 | left by 1 | 0000 1100 | 12 |
| 0001 0011 | 19 | left by 2 | ||
| 1010 1000 | 168 | right by 3 | ||
| 0000 1111 | 15 | right by 2 | ||
| 1100 0101 | 197 | left by 1 |
- Shift one place at a time, and write down the pattern after each.
- A left shift puts 0 in at the right. A right shift puts 0 in at the left.
- Check the denary value by multiplying or dividing the start value by 2 once for each place.
Show the completed table
| Start | Start in denary | Shift | Result | Result in denary |
|---|---|---|---|---|
| 0000 0110 | 6 | left by 1 | 0000 1100 | 12 |
| 0001 0011 | 19 | left by 2 | 0100 1100 | 76 |
| 1010 1000 | 168 | right by 3 | 0001 0101 | 21 |
| 0000 1111 | 15 | right by 2 | 0000 0011 | 3 |
| 1100 0101 | 197 | left by 1 | 1000 1010 | 138 |
Check your understanding
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
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
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
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
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
Check your understanding
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.
The number system with only two digits, 0 and 1, in which each column is worth twice the column to its right.
A single binary digit: 0 or 1. The smallest unit of data a computer stores.
The everyday number system with ten digits, 0 to 9, in which each column is worth ten times the column to its right.
The bit at the right-hand end of a binary number, which is worth the least.
Moving every bit of a binary number a set number of places left or right, losing the bits that move off the end and filling the gap at the other end with zeros.
The bit at the left-hand end of a binary number, which is worth the most.
A very small, very fast storage location inside the CPU that holds a fixed number of bits: the address, data or instruction the CPU is working on at that moment.
Your progress on this lesson
Saved in this browser only. It is not sent anywhere, does not follow you to another device, and is lost if you clear this site’s data.
This browser is not allowing the site to save progress, so it will be forgotten when you leave the page.