You can use the logical operators AND (&&), OR (||), and NOT (!) to evaluate expressions. The result of the operation is a 1 if the operation is true and 0 if the operation is false.
For the logical AND, the result of the operation is true (1) if the values of the expressions to the left and right of the operator are both nonzero. The result of the operation is false (0) if either value is zero. The evaluation halts when an expression is evaluated as zero.
For the logical OR, the result of the operation is true (1) if the values of the expression on either the left or right of the operator is nonzero. The result of the operation is false (0) if both values are zero. The evaluation halts when an expression is evaluated as nonzero.
The NOT operator must precede the operand. The operation inverts the value of the operand; that is, a nonzero expression becomes 0, and a zero expression becomes 1. For the logical NOT, the result of the operation is true (1) if it evaluates to zero, or false if it evaluates to nonzero.
Example
<# i := 6; i >= 3 && i <= 10 #>The result is 1 <# i := 1; i >= 3 && i <= 10 #>The result is 0 <# i := 6; i >= 3 || i <= 10 #>The result is 1 <# i := 1; i >= 3 && i <= 10 #>The result is 0 <# i := 5; !i #> The result is 0 <# i := 5; j := 0; !i && !j #>The result is 0 <# i := 5; j := 0; !i || !j #>The result is 1
Relational operators have a higher precedence than logical AND and OR. The NOT operator is equal in precedence to the increment and decrement operators.