Quiz Entry - updated: 2026.07.07
What is the difference between logical left shift and logical right shift?
Left shift (<<) moves bits toward the high end, filling vacated low bits with 0; logical right shift (>>) moves bits toward the low end, filling vacated high bits with 0.
x << 3: Argument x: 01100010
Result: 00010000 (shifted left 3, filled 0s)
x >> 2: Argument x: 10100010
Result: 00101000 (shifted right 2, filled 0s)
Effect:
- Left shift by k = multiply by 2^k
- Right shift by k = divide by 2^k (for unsigned)