B = 0000 1101
A&B = 0000 1100
AB = 0011 1101
A^B = 0011 0001
~A = 1100 0011
The following table lists the bitwise operators supported by C. Assume variable 'A' holds 60 and
variable 'B' holds 13, then −
Show Examples
Operator
Description
Example
&
Binary AND Operator copies a bit to the result if it exists in
both operands.
(A & B) =
12, i.e.,
0000 1100

Binary OR Operator copies a bit if it exists in either operand.
(A  B) =
61, i.e.,
0011 1101
^
Binary XOR Operator copies the bit if it is set in one operand
but not both.
(A ^ B) =
49, i.e.,
0011 0001
~
Binary Ones Complement Operator is unary and has the effect
of 'flipping' bits.
<<
Binary Left Shift Operator. The left operands value is moved
left by the number of bits specified by the right operand.
(~A ) = 60,
i.e,. 1100
0100 in 2's
complement
form.
A << 2 =
240 i.e.,
1111 0000
Leave your Comments