Bitwise operators
Operator Description
& The bitwise AND operator that compares bits and returns 1 when each bit equals 1. Otherwise, 0 is returned.
| The bitwise OR operator that compares bits and returns 1 when at least one of the bits equals 1. Otherwise, 0 is returned.
^ The bitwise XOR operator that compares bits and returns 1 if exactly one of the bits equals 1. Otherwise, 0 is returned.
~ The bitwise negation operator that inverts all bits in a specified number. All 0 bits are converted to 1, and all 1 bits are converted to 0.
<< The bitwise shift left operator that shifts all bits to the left by the specified number of positions.
>> The bitwise shift right operator that shifts all bits to the right by the specified number of positions.
Related examples in the same category