C examples for Operator:Bit Operator
The bitwise operators operate on the bits in integer values.
There are six bitwise operators, as shown in the following table.
Operator | Description |
---|---|
& | Bitwise AND operator |
| | Bitwise OR operator |
^ | Bitwise Exclusive OR (XOR) operator |
~ | Bitwise NOT operator, also called the 1's complement operator |
>> | Bitwise shift right operator |
<< | Bitwise shift left operator |
All of these only operate on integer types.
The ~ operator is a unary operator as it applies to one operand and the others are binary operators.
The bitwise AND operator, &, combines the corresponding bits of its operands. If both bits are 1, the resulting bit is 1; otherwise, the resulting bit is 0.