For example ,for these similar codes when I'm writing it like the first pattern the condition gets true and in the second pattern the condition gets false.
I have watched the values of mask & (bits >> i)
and mask
in real-time in the debugger tool and although they were the same the condition returned false.
Why this weird behavior happening?
1:
void printLetters(unsigned int bits, unsigned int i) // 0<i<7
{
unsigned int mask = 0x1;
unsigned temp;
temp = mask & (bits >> i);
if (temp == mask) //the same condition in other way
printf("true");
}
2:
void printLetters(unsigned int bits, unsigned int i) // 0<i<7
{
unsigned int mask = 0x1;
if (mask & (bits >> i)== mask) //the same condition in other way
printf("true");`
}