strcat(b, ((x & z) == z) ? "1" : "0");
I understand strcat()
function and the conditional (ternary) operator. But I don't know what (x & z) == z
means.
&
is the bitwise AND operator.
here, (x & z) == z
means, perform a bitwise AND of x
and z
and if that value equals to z
, then....
Ref: Chapter 6.5.10, C11
standard, "Bitwise AND operator"
The result of the binary
&
operator is the bitwise AND of the operands (that is, each bit in the result is set if and only if each of the corresponding bits in the converted operands is set).