Logical Operators in C

&& 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.


The && is a logical AND (as opposed to &, which is a bitwise AND). It cares only that its operands as zero/non-zero values. Zeros are considered false, while non-zeros are treated as true.

In your case, both operands are non-zero, hence they are treated as true, resulting in a result that is true as well. C represents true as 1, explaining the overall result of your operation.

If you change the operation to &, you would get a bitwise operation. 0x65 & 0x55 will give you a result of 0x45.