Signed integers use the high-order bit to denote sign.
So >>
preserves the sign, while >>>
doesn't. This is why >>
is referred to as the arithmetic shift and >>>
is the logical shift.
This way, you can do (assuming 32-bit integers) the following:
-10 >> 1
yields -5 (0xFFFFFFF6 >> 1
yields 0xFFFFFFFB - notice the high-order bit stays the same.)
-10 >>> 1
yields 2147483643 (0xFFFFFFF6 >>> 1
yields 0x7FFFFFFB - notice all of the bits were shifted, so the high-order bit is now zero. The number is no longer negative according to twos-complement arithemetic.)
For positive integers, >>
and >>>
act the same, since the high-order bit is already zero.
It also explains why there is no need for a <<<
operator. Since the sign would be trashed by sliding the bits to the left, it would map to no reasonable arithmetic operation.