a & 8 == 8
is a & (8 == 8)
because ==
has higher precedence than &
(here)
So 8 == 8
is 1
and a = 10
which is 1010
in binary
So
00000001
& 00001010
--------
00000000
Interesting fact:
Although false is a zero and true is any non-zero value in C Language. But, if the equality operator evaluates to be true it guarantees to evaluate to the value 1
and 0
otherwise. Referrer C99 Section 6.5.9 Paragraph 3