When you shift an integer with the character <or β, and the shift distance is greater than or equal to 32, you take the shift distance of mod 32 (in other words, you mask everything except 5 bits of shift).
This can be very controversial. For example (i >> 32) == i , for each integer i. You can expect it to shift the entire number to the right, returning 0 for positive inputs and -1 for negative inputs, but this is not the case; it just returns i because (i << (32 & 0x1f)) == (i << 0) == i .
Returning to the original problem, (i <<33) == (i <(33 and 0x1f)) == (i <1). You can do it all in binary if you want. 270 in binary: 0000 0000 0000 0000 0000 0000 0001 0000 1110 Offset to the right by 1, you get: 0000 0000 0000 0000 0000 0000 1000 1000 0111, which is 135.
But the best way to make this problem in your head is to completely abandon binary code. The value i >> s is floor(i / 2<sup>s</sup>) (where s is already masked, so it is less than 32). So, 270 << 1 = floor(270/2) = 135 .
http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.19
source share