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
Bitwise Operators in Kotlin
Comments¶
When you use
1L shl 2
,shl
is considered as the left-shift operator instead of a method call.Bitwise operators are computed from left to the right.
Bitwise operators have relatively low priority (lower than arithmatic operators), It is suggested that you use parentheses when you mix lower precendenc (bitwise opertors, ternary opertor, etc.) and high precendenc operators together. A even better approach in Kotlin is to avoid using bitwise operators and use the corresponding methods instead.