Number Systems
Data Representation
A logical binary shift is the operation of moving every bit of a binary number a fixed number of places to the left or to the right. Bits that fall off the end of the register are lost; the vacated positions are filled with 0s.
Logical left shift
A logical left shift by 1 moves every bit one position to the left. The leftmost bit falls off; a 0 is filled in on the right.
The effect on the value is to multiply by 2 (provided no 1-bit falls off the end):
- Left shift by 1 = ×2
- Left shift by 2 = ×4
- Left shift by 3 = ×8
- Left shift by n = ×2ⁿ
Logical right shift
A logical right shift by 1 moves every bit one position to the right. The rightmost bit falls off; a 0 is filled in on the left.
The effect on the value is to divide by 2 (integer division, with no remainder):
- Right shift by 1 = ÷2
- Right shift by 2 = ÷4
- Right shift by n = ÷2ⁿ
When information is lost
If a 1 is shifted off either end of the register, the simple ×2ⁿ or ÷2ⁿ rule no longer holds and information is lost:
- On a left shift, losing a 1 means the result is smaller than the true product. This is an for shifts.
- On a right shift, losing a 1 means the result is rounded down (the lost place value is discarded).
Common exam question
Performing a logical shift and stating its effect
Question: Give the 8-bit number or register contents after a logical shift, describe the process, or state its effect (1–2 marks per part).
Asked in 6 of the 17 papers. Move every bit the stated number of places, drop the bits that fall off the end and fill the gaps with 0s, keeping eight bits (a left shift of three turns 00110101 into 10101000). Left shifts multiply by 2 per place and right shifts divide by 2 per place; a two-mark effect question wants operation and factor: a right shift of four places is "divide" (one mark) "by 16, or 2⁴" (the second).
A description of a left shift scores for any two of: every bit moves one place left, the most significant bit is lost, a 0 fills the least significant bit. Losing bits off the end makes the value inaccurate, another credited effect, and the multiple-choice version asks which bits a left shift loses: the most significant.