YOP. if a is an int (or an integral to be more precise), a&1 returns all bits cleared but the first one.
Thus it does not really "compares with 1".. except when used as a bool; for all integrals are implicitely convertible to bool in C++.
e.g. if (a&1) is equivalent to if (a%2!=0) or if (a&1!=0) or if (a&1==true)
YOP. if a is an int (or an integral to be more precise), a&1 returns all bits cleared but the first one.
Thus it does not really "compares with 1".. except when used as a bool; for all integrals are implicitely convertible to bool in C++.
e.g.
if (a&1)
is equivalent toif (a%2!=0)
orif (a&1!=0)
orif (a&1==true)
see https://en.cppreference.com/w/cpp/types/is_integral