Logical operators

Logical operators apply standard boolean algebra operations to their operands.

Operator Operation Example Result
! Logical NOT !a 1 if a = 0, else 0
&& Logical AND a && b 1 if both a ≠ 0 and b ≠ 0, else 0
|| Logical OR a || b 0 if both a = 0 and b = 0, else 1