Java operator>,>>,>>>The difference between the three

> Means greater than

Such as: if (a>b)... the result is a boolean type.

>> means move right with sign

Such as: int i=15; the result of i>>2 is 3, and the removed part will be discarded.
Converting to binary form may be better understood, the result of shifting 0000 1111(15) to the right by 2 bits is 0000 0011(3). The result of shifting 0001 1010(18) by 3 bits to the right is 0000 0011(3).

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

Guess you like

Origin blog.csdn.net/qq_43191910/article/details/114987528