Java operators >, > >, and > > >

>Indicates greater than, for example: if (a > b) The result is a boolean type

>>Indicates a signed right shift, such as int i = 15; i> The result of > 2 is 3, and the removed part will be discarded. It may be better understood that the result of shifting 2 bits to the right of 0000 1111 (15) is 0000 0011 (3), and the result of shifting 3 bits to the right of 0001 1010 (18) is 0000 0011 (3).

>>>Unsigned right shift: move all numbers to the right in binary form, corresponding to towering digits, move out (discard) the low bits, and fill in zero for the high bits. For positive numbers, it is the same as signed right shift, but different for negative numbers. Other structures are similar to > >.

The test code is as follows:

Other bitwise operators in Java:

~Bitwise non (not) (unary operation) & bitwise and (and) | bitwise OR (or) ^ bitwise XOR (XOR) > > shift right > > > shift right, the bits left are filled with 0 < < shift left & = bitwise and assignment | = bitwise or assignment ^ = bitwise XOR assignment > > = shift right assignment > > = shift right assignment, and the bits left are filled with 0 < < = shift left assignment

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>