Bitwise Operators
In the following lesson, you will be introduced to bitwise operators.
Types of Bitwise Operators
Bitwise operators are operators that perform operations on individual bits of integer types. Below is a list of the bitwise operators supported by Scala.
Operator | Name | Use |
---|---|---|
& |
Bitwise AND | If the corresponding bit in both operands is 1 it will give a 1, else 0 |
| |
Bitwise OR | If the corresponding bit in at least one operand is 1 it will give a 1 else 0 |
^ |
Bitwise XOR | If the corresponding bit in only one operand is 1 it will give a 1 else 0 |
~ |
Bitwise Ones Complement | Copies a bit to the result after reversing it |