OCR · GCSE · Computer Science
Course version: J277 · Version from Sept 2022
Data storage: Binary shifts
A binary shift moves every bit in a binary pattern a stated number of places left or right.
Checked against the OCR J277 specification on .
- Point 5 of 13
- 4 key terms
Study notes
From the checked teaching notes for this specification point.
The idea
A binary shift moves every bit in a binary pattern a stated number of places left or right. A left shift by n places multiplies the value by 2ⁿ, because each bit moves to a place value n positions higher. A right shift by n places divides the value by 2ⁿ, discarding any bits shifted past the right-hand end and losing fractional parts. For example, 00010110 (22) shifted left by 2 gives 01011000 (88), which is 22 × 2². The same pattern shifted right by 1 gives 00001011 (11), which is 22 ÷ 2. Bits shifted out of the fixed-width register are lost, and zeros fill the vacated positions. This means a left shift can cause an overflow error if significant bits are lost, changing the value unexpectedly, while a right shift causes a loss of precision.
What earns the marks
- Moving every bit the stated number of positions in the stated direction, keeping the remaining bits in their relative order.
- Filling vacated positions with zeros rather than copying existing bits or leaving gaps.
- Recognising that a left shift by n places multiplies the original value by 2ⁿ, for example a left shift by 3 multiplies by 8.
- Recognising that a right shift by n places divides the original value by 2ⁿ, discarding any remainder, for example a right shift by 2 divides by 4.
- Identifying bits shifted beyond the available width as lost, which can cause overflow on a left shift or loss of precision on a right shift.
- Calculating the new denary value by applying the multiplication or division, or by re-evaluating the place values of the shifted pattern.
Common mistakes and how to put them right
Shifting in the wrong direction, which changes multiplication into division.
Put it right by checking whether the value should increase (left) or decrease (right).
Forgetting to fill empty positions with zeros, which produces a pattern with missing bits.
Put it right by writing the full-width result with zeros in every vacated position.
Assuming a right shift rounds to the nearest integer, when it truncates the fractional part.
Put it right by discarding the remainder, so 00000101 (5) shifted right by 1 gives 00000010 (2).
Exam tips
- Write the original pattern with place values above the bits so you can track each bit as it moves.
- State the arithmetic effect as well as the new pattern, for example left shift by 2 multiplies by 4, to show full understanding.
- Check for overflow by comparing the number of bits needed for the new value with the fixed width of the register.
Try the lesson
The start of the Data storage: Binary shifts lesson, made from checked teaching notes for this specification point.
Have a go first
What is the result of applying a logical left shift of two places to the binary number 00001010?
Listen
A binary shift moves every bit in a binary pattern a stated number of places left or right. A left shift by n places multiplies the value by 2ⁿ, because each bit moves to a place value n positions higher. A right shift by n places divides the value by 2ⁿ, discarding any bits shifted past the right-hand end and losing fractional parts. For example, 00010110 (22) shifted left by 2 gives 01011000 (88), which is 22 × 2². The same pattern shifted right by 1 gives 00001011 (11), which is 22 ÷ 2. Bits shifted out of the fixed-width register are lost, and zeros fill the vacated positions. This means a left shift can cause an overflow error if significant bits are lost, changing the value unexpectedly, while a right shift causes a loss of precision. A strong answer earns marks for these points. Moving every bit the stated number of positions in the stated direction, keeping the remaining bits in their relative order. Filling vacated positions with zeros rather than copying existing bits or leaving gaps. Recognising that a left shift by n places multiplies the original value by 2ⁿ, for example a left shift by 3 multiplies by 8. Recognising that a right shift by n places divides the original value by 2ⁿ, discarding any remainder, for example a right shift by 2 divides by 4. A common slip: Shifting in the wrong direction, which changes multiplication into division. Instead, checking whether the value should increase (left) or decrease (right). Exam tip: Write the original pattern with place values above the bits so you can track each bit as it moves.
See it
Key words
Say what each word means before you turn the card.
Binary shift
Try answering aloud or in your head before turning the card.
Multiplication and division by powers of two
Try answering aloud or in your head before turning the card.
Overflow
Try answering aloud or in your head before turning the card.
Loss of precision
Try answering aloud or in your head before turning the card.
See every definition
- Binary shift
- A binary shift moves every bit in a binary pattern a stated number of places left or right.
- Multiplication and division by powers of two
- A left shift by n places multiplies the value by 2ⁿ, while a right shift by n places divides the value by 2ⁿ, discarding any bits shifted past the right-hand end.
- Overflow
- A left shift can cause an overflow error if significant bits are lost, changing the value unexpectedly.
- Loss of precision
- A right shift causes a loss of precision, discarding any bits shifted past the right-hand end and losing fractional parts.
There is more to this lesson
The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge
Test your understanding of Data storage: Binary shifts
Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge