C Programming – Understanding Logical Operators

c++logical-operators

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 to 1 otherwise it evaluates to 0.

If the left operand is 0, the right operand is not evaluated and the result is 0.

0x65 && 0x55 is evaluated to 1.

Related Question