posted 24 years ago
The << operator causes the bits of the left operand to be shifted to the left, based on the value of the right operand. The new bits that are used to fill in the shifted right bits have the value 0. Figure A illustrates the process of shifting left. Note that the leftmost bits shifted out of the operand are discarded.<br /> The >> operator causes the bits of the left operand to be shifted to the right, based on the value of the right operand. The bits that fill in the shifted left bits have the value of the leftmost bit (before the shift operation). The >> operator is said to be a signed shift because it preserves the sign (positive or negative) of the operand. Figure B illustrates how the signed right shift is performed. The right-most bits that are shifted out of the operand are discarded.
The >>> operator is identical to the >> operator, except that the bits that fill in the shifted left bits have the value of 0. The >>> operator is said to be an unsigned shift because it does not preserve the sign of the operand.
Refer to JLS for more details.