Bitwise Expression
Bitwise expressions are used to perform bitwise operations on integers. These operations are performed on the binary representation of the numbers and manipulate the individual bits of the number.
Syntax
Bitwise AND, OR and XOR
Bitwise NOT
Bitwise Shift
Examples
Bitwise AND
Bitwise OR
Bitwise XOR
Bitwise NOT
Bitwise Shift
Chained Bitwise Expressions
Bitwise expressions may be also chained together as long as you want. For example:
Precedence
The precedence of bitwise expressions is as follows:
- Bitwise Shift
- Bitwise AND
- Bitwise XOR
- Bitwise OR
Chained Bitwise Expressions
Chained bitwise expressions are evaluated from left to right.
In this example, the bitwise AND operation is evaluated first, followed by the bitwise OR operation.
You can also use parentheses to change the order of evaluation.
A more complicated example may look like this: