Logical Left Shift
In a left shift each bit is simply moved to the left with the empty space on the right replaced with zero.
Notice the ones have moved along 2 spaces
Logical Right Shift
In a logical right shift the bits are shifted to the right and the most significant bit(empty bit to the left ) is replace with zero. The least significant bit(Any bit falling off the right) is discarded
0011001 >>1 0001100
Some programming languages don’t have an in-built logical right shift, they only have an arithmetic right shift.
Arithmetic Left Shift
Arithmetic left shifts work the same as logical left shifts. The bit is shifted to the left (the sign bit is discarded) with zeroes add at the right hand end.
Arithmetic Right Shift
In an arithmetic right shift the bit is shifted to the right but the most significant bit is copied to the next most significant bit position on the left.
This is used when the most significant bit is the sign bit (1s/2s Compliment) indicating + / – value. The least significant bit is discarded.
1011 >>1 1101
These shifts can be performed either left or right. No data is discarded as the bit that falls off one end is added to the other end.
10110011 Shift 3 Right 01110110
Past Paper Exam Questions