OK the first thing to point out is that:
if the left-hand side is an int then the right-hand side is ANDed with 0x1F and if the left-hand side is a long then the right-hand side is ANDed with 0x3F.
Now, let's take a look at 2<<3 and 2<<-3.
2<<3 : No suprises here the result is 16 as expected.
BUT for 2<<-3 the story is different.
the right-hand side (-3) in binary is
11111111 11111111 11111111 11111101
and ANDed with 0x1F it gives
11101 which is in fact 29 (32-3) and the result of the shifting is 1073741824.
To summarize: the right-hand side is in all cases ANDed with 0x1F (or 0x3F) and that result is the one used in the shifting operation. So there is no way to shift more than 31 positions (to the left or to the right) because of that AND operation whatever the sign of the rigth-hand side is.
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for
Java 2 Platform