Bitwise AND adds bits together, and if two 1's line up, it's a 1, otherwise, it's a 0, like so, yes?
So, in an if statement:Code:0011
& 1010
= 0010
So that means if just one of the resulting bits is 1, the condition is true?Code:int y=2; //0010
if (y & 3)//0011
{
cout<< "This is true.";
}
So saying if (y & 3) is the same as saying if (y==1 || y==2 || y==3), yes?