According to my previous learning knowledge, the rules of << and >> operations are as follows:
<<: Left-shift operation: is the current binary number to the left to move how many bits, the low empty out of the complement 0. Discard >> of high-level emigration;: Right shift operation: is the current binary number of the right to move how many bits, high-empty, the original highest is what, what to fill, low displacement in addition to the discard. Look at the following questions:
Public classDemo { Public Static voidMain (string[] args) {intA =123; intb = a >> +; intc = a >> -; System. out. println (a); System. out. println (b); System. out. println (c); }}
Output Result:
123123123
It seems that this conclusion is not so correct, according to the experiment, according to the data type, int---32 bit a period; long--64-bit one cycle. So loop, not just a simple complement.
On the problems of left-shift and right-shift operation in bit operation