Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
The Bitwise operators has relative low precedence. They have lower precedence than arithmatical operators. It is suggested that you use parentheses when you mix lower precendenc (bitwise opertors, ternary opertor, etc.) and high precendenc operators together.
There is no unsigned left shift operator in Java. https://
www .quora .com /Why -is -there -no -unsigned -left -shift -operator -in -Java
System.out.println(1 << 5)32
nullSystem.out.println(1 << 5 - 1)16
nullSystem.out.println(1 << 30)1073741824
nullSystem.out.println(1 << 31)-2147483648
nullSystem.out.println(Integer.toBinaryString(1 << 31))10000000000000000000000000000000
nullThe shift oprator is cyclical.
System.out.println(Integer.toBinaryString(1 << 32))1
nullUnsigned Right Shift Operator (>>>)¶
System.out.println(1 >>> 31);0
nullSystem.out.println(Integer.toBinaryString(-4))11111111111111111111111111111100
nullSystem.out.println(-4 >>> 28);15
nullSystem.out.println(Integer.toBinaryString(-1))11111111111111111111111111111111
nullSystem.out.println(-4 >> 28)-1
nullSystem.out.println(1 <<< 3);illegal start of type
System.out.println(1 <<< 3)
^
illegal start of expression
System.out.println(1 <<< 3)
^^
')' expected
System.out.println(1 <<< 3)
^
';' expected
^
reached end of file while parsing
}
^System.out.println(1 << 32)1
nullSystem.out.println(1 << 33)2
nullSystem.out.println(~0)-1
nullSystem.out.println(Integer.toBinaryString(-1))11111111111111111111111111111111
null