1. Bit Shift Operators
2. General Syntax of Shift Operators
value
value >> num-bits: Moves the value bits to the right, preserving the sign bit.
value >>> num-bits: Moves the value bits to the right by inserting zeros on the left.
3. Left Shift
4. Shift to the Right
5. Shift to the Right No Sign (>>>)
6. Displacement is not rotational
Example:
Left and Right Shift
*ShiftDemo *
Care when Shifting Byte and Short Values
Example:
Abbreviated Assignments with Bitwise Operators
Example
x = x ^ 127; x ^= 127;
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3