If the promoted type of the left-hand operand is int, only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & with the mask value 0x1F . The shift distance actually used is therefore always in the range 0 to 31, inclusive.
Hi Amit, To make sure that the value always falls in 0-31(inclusive) range,the compiler masks it with 0x1F,the explanation has been provided by Ariel,I am showin you the example in detail:
I have thought of a short-cut method,but i dont knw how far it would work. For eg. if it's x >> -3,it changes to x >> 29 (i.e 32-3). For,x << -4,it changes to x << 28 (i.e 32 - 4). lolz..hopes that helps!!!