GCSE · Computer Science · Edexcel · Spec 1CP2
Logical binary shifts
Double 150 by shifting its bits left in 8 bits and the computer says 44. No warning, just a confident wrong answer. Where did the missing bit go?
Computer Science · Data
Slide the bits along
One 8-bit number, shifted one place at a time. Watch where the 0s step in and which bit falls off the end.
Before you step through: each time every bit moves one place left, what do you think happens to the denary value?
1 START: 000110102 SHIFT LEFT 1 place3 SHIFT LEFT 1 place again4 START AGAIN: 000110105 SHIFT RIGHT 1 place6 SHIFT RIGHT 1 place again
| 8-bit pattern | Denary | What fills the gap | Bit that falls off |
|---|---|---|---|
| 00011010 | 26 | - | - |
Output
Step 1: Eight boxes, eight bits, and that never changes. This pattern is 16 + 8 + 2 = 26.
Press Next to move one place at a time, and compare each row with the one before it.
Predict, then check
Work it out as a division first, then think about what an 8-bit pattern can actually hold.
00001111 is 15 in denary. You shift it one place to the right in a logical shift. What is the denary value of the new pattern?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Slide the bits along, fill the gap with 0s, and watch the value double or halve, until a bit falls off the end.
What you need to know
- A binary shift moves every bit of a binary number some places to the left or to the right.
- Shifting left multiplies the number by a power of 2, and shifting right divides it by a power of 2.
Have a goSam says: "Shifting right makes a number bigger, because the bits are heading towards the big end." Is Sam right?
No. A right shift divides by a power of 2, so the number gets smaller.
Sam has the directions swapped: it's the left shift that multiplies and the right shift that divides.
- In a logical shift the gaps are filled with 0s: at the right-hand end for a left shift, the left-hand end for a right shift.
- Left shift by n places multiplies by 2^n, so 00011010 (26) shifted two places left is 01101000 (104).
Have a goHave a go: shift 00001001 (9) two places left in a logical shift. Where do the new 0s go, and what is the denary result?
00100100. The two 0s fill the right-hand end, and the result is 36.
Two places left multiplies by 2^2 = 4, and 9 × 4 = 36, so the denary check agrees with the pattern.
- Right shift by n places divides a whole number by 2^n, so 26 shifted one place right is 13, then 6.
- Bits shifted beyond the end of the available bits are lost. They are not carried round or copied.
Have a goYou shift 11110000 one place left in 8 bits. What do you get, and what happens to the far-left 1?
11100000. The far-left 1 falls off the end and is lost, and a 0 fills the gap on the right.
A bit shifted beyond the end of the available bits is lost. It does not wrap round to refill the gap.
- A left shift that loses a 1 gives a wrong answer, an overflow error: 10010110 shifted left once in 8 bits gives 00101100.
- A right shift loses whatever falls off the right-hand end, so the remainder is truncated. That is why 13 becomes 6, not 6.5.
- Overflow means a number is too large for the allocated memory. More binary digits avoid it but need more storage space.
- To check a shift, convert the number and your answer to denary.
The big picture
A binary shift slides every bit of a number left or right. In a logical shift the gaps are filled with 0s, so each place left multiplies by 2 and each place right divides by 2, until bits fall off the end and the answer goes quietly wrong.
Key points
Worked example
Problem
Shift 00001011 (11) two places left, and separately shift 00001011 two places right. Check both answers in denary.
⚠ Watch out
Thinking a bit that falls off the end wraps round to the other end, or is kept somewhere. In a logical shift it is lost, and the gap is filled with 0s, nothing else.
Memory hook
Slide, fill, lose: slide every bit along, fill the gap with 0, and lose whatever falls off the end. In denary, sliding the digits multiplies or divides by 10; in binary each slide is a 2.
Check yourself
Shift 00000111 two places left in a logical shift, then check your answer in denary. (Answer: 00011100, which is 28 = 7 × 4.)
Flashcards
(12)What is a binary shift?
What does a logical left shift by n places do to the value?
What does a logical right shift by n places do to a whole number?
In a logical shift, what fills the gaps, and where?
What happens to bits shifted beyond the end of the available bits?
Why does a right shift truncate?
What is an overflow error in a left shift?
What is overflow?
How do more bits help with overflow, and what is the cost?
How do you check a binary shift?
A left shift gives a result that is not the original times a power of 2. What might have gone wrong?
10010110 shifted left once in 8 bits: what do you get, and is it right?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore Edexcel GCSE Computer Science topics
How this lesson was checked. This Edexcel GCSE Computer Science (specification 1CP2)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 9 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.