&: Bitwise AND
|: Bitwise OR
^: Bitwise XOR
\>\>: Shift right
>>>: Unsigned shift right
<<: Shift left
~: One’s complement (unary NOT)
You can use these bitwise operators for the following data types.
Bitwise operators cannot work on …
Example 1: Getting upper case for a letter
The value 65,503 used in the AND statement is the decimal representation of 1111 1111 1101 1111. Thus, the AND operation leaves all bits in ch unchanged except for the 6th one, which is set to 0.
Iterating through bits
Example 2: Getting lower case for a letter
<<: left shift
>>: right shift
>>>: unsigned right shift