Specifications

Sun Services
Java™ Programming Language
Module 4, slide 12 of 31
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Right-Shift Operators >> and >>>
Arithmetic or signed right shift (>>) operator:
Examples are:
128 >> 1 returns 128/2
1
=64
256 >> 4 returns 256/2
4
=16
-256 >> 4 returns -256/2
4
= -16
The sign bit is copied during the shift.
Logical or unsigned right-shift (
>>>) operator:
This operator is used for bit patterns.
The sign bit is not copied during the shift.