Why are there two Right Shift statements and only one Left Shift statement in Java?

I am new to java and found out that there are two Right Shift statements in java >> and >>> , but only one left shift operator << . Why is this so?

+6
source share
2 answers

Since the logical and arithmetic operations with left shift are identical ( from wikipedia ).

RightLeft

RightLeft

Notice what happens with the bit sign (the leftmost bit) in left shifts.

+9
source

Right shift operators are ones with ( >> ) and one without ( >>> ) sign extensions. The left shift operation does not have a sign extension component.

For example, the following expressions are true:

 (0x80000000 >> 1) == 0xC0000000 (0x80000000 >>> 1) == 0x40000000 
+3
source

Source: https://habr.com/ru/post/904078/


All Articles