This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
The range of int primitive is -2^31 to (2^31) - 1.
and so (1 << 31) does not fit in an int and results in a negative number.
where as due to the masking of bits, when the value to be shifted is an int, for the shift values of >=32, the actual size of the shift is the value of the right-hand operand masked by 31. ie.the shift distance is always between 0 and 31. if shift value is > 32 shift is value%32
similarly for longs for the shift values of >=64, the actual size of the shift is the value of the right-hand operand masked by 63. ie.the shift distance is always between 0 and 63. if shift value is >= 64 shift is value%64
And this question tests one more concept,
in unsigned right shift operation, if the left-hand operand is negative, the result is equivalent to the left-hand operand right-shifted by the number indicated by the right-hand operand plus two left-shifted by the inverted value of the right-hand operand. So here -1 >>> 1 = (-1 >> 1) + (2 << ~1) = 2147483647.