Bit pattern of 2 = 00000010 Bit pattern of -1 = 11111111
If the shift distance value is greater than 32, the least five digits are taken as the shift distance. Here, the least five digits of the bit pattern of -1 is taken as the shift distance. Therefore, the shift distance becomes 31 (11111).
So, 2 >> 31 = 0.
Hope you get it!!
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!