Yours and my understanding of >> is the same (I'm not saying we're correct
), but I think your confusion is caused by how
Java represents ints: with two's complement notation.
A very very brief intro: If you have a positive bit
pattern say, 0000 1010 (int +ten, in 8-bit two's complement), you get its corresponding negative by
flipping the bits and adding one. So, in this case we flip the bits to '1111 0101', and add one to get '1111 0110'. That last pattern is -ve ten, in two's complement.
In any case, you can Google for a better explanation or just play around with it yourself:
Yields:
--Tim