The
bitwise operators perform bit by bit operation on the values of the two
operands.
Operator
|
Description
|
& (binary and)
|
If both the bits at the same place in
two operands are 1, then 1 is copied to the result. Otherwise, 0 is copied.
|
| (binary or)
|
The resulting bit will be 0 if both
the bits are zero otherwise the resulting bit will be 1.
|
^ (binary xor)
|
The resulting bit will be 1 if both
the bits are different otherwise the resulting bit will be 0.
|
~ (negation)
|
It calculates the negation of each
bit of the operand, i.e., if the bit is 0, the resulting bit will be 1 and vice versa.
|
<< (left shift)
|
The left operand value is moved left
by the number of bits present in the right operand.
|
>> (right shift)
|
The left operand is moved right by
the number of bits present in the right operand.
|
0 comments:
Post a Comment