Boolean and bitwise operators

Jai has a number of boolean operators, namely:

  • ! - boolean NOT
  • || - boolean OR
  • && - boolean AND

Additionally, it has a number of bitwise operators:

  • | - bitwise OR
  • & - bitwise AND
  • ^ - bitwise XOR
  • << - shift left
  • <<< - rotate left
  • >> - shift right
  • >>> - rotate right
  • ~ - bitwise NOT (one’s complement) (unary)

The bitwise operators perform an arithmetic shift, following C’s rules regarding bitwise operators.

Bitwise AND compares the respective bits between two numbers together. If both respective bits are 1, then the output is 1. If either respective bits are 0, then the output is zero.

  11001100
& 10001000
----------
= 10001000

Bitwise OR compares the respective bits between two numbers together. If either respective bits are 1, then the output is 1. If both respective bits are 0, then the output is zero.

  11001100
| 10000011
----------
= 11001111