Java provides two right-shift operators, which belong to bit operators. The bitwise operator is used to manipulate the bits. >>: Arithmetic Right shift operator, also known as symbol right shift. Fill the left empty space with the top >>>: Logical Right Shift operator, also known as unsigned Right shift. To operate on bits only, fill the left empty space with 0. The expression is: R = e1 >> E2;r = E1 >>> E2; Moves the number E1 right to the E2 bit. Operation rules:>>: In binary form, all the numbers to the right to move the corresponding number of digits, low-off (discard), high position of the vacancy complement the sign bit, that is, positive complement 0, negative complement 1. The
sign bit does not change. >>>: In binary form, all numbers are shifted to the right by the corresponding number of digits, the lower position is removed (discarded), and the upper slot is 0. For positive numbers, it is the same as a signed right shift, which is different for negative numbers. Press Previous, 1 is represented in 32-bit binary as: 11111111 11111111 11111111 11111111-1>>1: Bitwise right SHIFT, symbol bit unchanged, still get
11111111 11111111 11111111 11111111 Therefore the value is still-1 and the result of -1>>>1 is 01111111 11111111 11111111 11111111
Java right-shift operators >> and >>>