Binary Shifts
A binary pattern has a fixed width, such as 8 bits. When a shift moves a bit past either end, that bit is gone: it is not wrapped round to the other end. This matters because the value you keep can be smaller or less exact than the true result.
A right shift divides by a power of two, but the bits that fall off the right-hand end are discarded. For a positive number this means the result is rounded down. For example, the 8-bit unsigned pattern 00110101 (53) shifted right by one place becomes 00011010 (26). The final 1 is discarded, so 53 ÷ 2 = 26.5 becomes 26.
For an arithmetic right shift of a negative two's complement number, the effect is to round towards negative infinity. The 8-bit pattern 11111001 represents -7. Shifted right by one place it becomes 11111100, which is -4. The true answer -3.5 has been rounded down, not towards zero.
A left shift multiplies by a power of two, but any 1 bits pushed beyond the most significant bit are lost. If this changes the value, the shift has caused overflow. For example, the 8-bit unsigned pattern 10011100 (156) shifted left by one place becomes 00111000 (56). The leading 1 has been shifted out of the fixed-width pattern, so the result is not 312.
The result of any shift therefore depends on its direction, how many places it moves and the fixed width of the pattern.
Edexcel GCSE Computer Science · Binary Shifts