I am having trouble trying to understand how logical operators work in C. I already understand how the bit-level operators work, and I also know that logical operators treat nonzero arguments as representing TRUE and zero arguments as representing FALSE
But say we have 0x65 && 0x55. I do not understand why and how this operations gives 0x01.
I tried to convert it to binary, but I cannot figure out how it works
Best Answer
&&
operator:If the left operand and the right operand are both different than
0
it evaluates to1
otherwise it evaluates to0
.If the left operand is
0
, the right operand is not evaluated and the result is0
.0x65 && 0x55
is evaluated to1
.