Check into how to use the Bitwise-AND Operator: &
The following is from the MSDN library regarding the Bitwise-AND Operator: &
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