Operators

Operators

Visit this site KNow more about Operators:

 

Bitwise operations

  • Kotlin provides a set of bitwise operations on integer numbers.
  • They operate on the binary level directly with bits of the numbers' representation.
  • Bitwise operations are represented by functions that can be called in infix form.
  • They can be applied only to Int and Long:
val x = (1 shl 2) and 0x000FF000
Here is the complete list of bitwise operations:
  1. shl(bits) – signed shift left
  1. shr(bits) – signed shift right
  1. ushr(bits) – unsigned shift right
  1. and(bits) – bitwise AND
  1. or(bits) – bitwise OR
  1. xor(bits) – bitwise XOR
  1. inv() – bitwise inversion