Because in Java there are no unsigned datatypes, there are two types of right shifts: arithmetic shift >>
and logical shift >>>
. http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op3.html
Arithmetic shift >>
will keep the sign bit.
Unsigned shift >>>
will not keep the sign bit (thus filling 0
s).
(images from Wikipedia)
By the way, both arithmetic left shift and logical left shift have the same result, so there is only one left shift <<
.