Bitwise And Operation
Posted on 1998-02-02
I am confused on Bit Comparisons. When doing a comparison of two bit values -> example
if ((nFlags & MK_LBUTTON)==MK_LBUTTON)
Assuming that MK_LBUTTON = 00000001 and nFlags was Unknown
If nFlags was equal to 01010101 , the if statement would be true? or does nFlags have to 00000001? Basically what I am asking is that when doing the comparision is it checking for only the one in the last bit or is it comparing the entire byte? Can someone explain how this all works and what it might be useful for?