AND-expression :
relational-expression
AND-expression & equality-expression
The bitwise-AND operator (&) compares each bit of its first operand to the corresponding bit of its second operand. If both bits are 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.
Example
In the following example, the bitwise-AND operator (&) compares the bits of two integers, nNumA
and nNumB
:
// Example of the bitwise-AND operator
int nNumA=1, nNumB=3, nNumC; // 00000001, 00000011
nNumC = nNumA & nNumB; // nNumC is now 1
For related information, see bitwise-exclusive-OR, bitwise-inclusive-OR, shift operators, and one's complement.