From [hidden link–devolved into a malicious site]
When the value to be shifted (left-operand) is an int, only the last 5 digits of the right-hand operand are used to perform the shift. The actual size of the shift is the value of the right-hand operand masked by 31 (0x1f). Ie the shift distance is always between 0 and 31 (if shift value is > 32 shift is 32 % value)
35 00000000 00000000 00000000 00100011
31 -> 0x1f 00000000 00000000 00000000 00011111
& -----------------------------------
Shift value 00000000 00000000 00000000 00000011 -> 3
-29 11111111 11111111 11111111 11100011
31 -> 0x1f 00000000 00000000 00000000 00011111
& -----------------------------------
Shift value 00000000 00000000 00000000 00000011 -> 3
What does that really mean? Does it mean for right shift, the maximum you can multiply is with 32? Is this to prevent overflow?
It’s not that the maximum you can multiply by is 32, it’s 2^31. (Bit shifting is exponentiation, not multiplication)
Considering that integers only have 32 bits, what would you expect to happen if you shifted by more then 31 bits anyway? You’d end up with the exact same result regardless of your input value – all of its its bits would have been shifted “off the end” – so it would serve no purpose whatsoever as an operation.