byte & short values (& also char) are promoted to int when an expression is evaluated which means that the outcome of a left shift on a byte or short will result in an int.
That said , here are the binary representations -
00000000000000000000000000000010 --> 2
01000000000000000000000000000000 --> 2 << 29
Now , 2 << 30 will yield
10000000000000000000000000000000 --> 2 << 30
And hence the negative value.
"Thus a left or right shift (<< and >>) will never cause a number to change its sign. A positive number will always stay positive and a negative number will always stay negative."
I beleive the quotes are wrong . Only a right shift ( >> ) can help with preserving the sign of a number.
[This message has been edited by Ashish Hareet (edited August 25, 2001).]