Example: Logical operators in expressions

These are the examples of logical operators in expressions.
Symbol (Function)
Description
Example: If tag1 = 5 and tag2 = 7, then:
&& (Logical AND)
Returns a value of 1 if the statements to the right and to the left of the operator are both true (non-zero).
(tag1 < tag2) && (tag1 == 5)r
eturns a 1 because both statements are non-zero (true)
tag1 && tag2 r
eturns a 1 because both tag1 and tag2 are non-zero (true)
ll (Logical OR)
Returns a value of 1 if either the statement to the left or to the right of the operator is true (non-zero).
(tag1 > tag2)
ll
(tag1 == 5)r
eturns a value of 1 because tag1 == 5 is true
! (Logical NOT)
Inverts the Boolean value of an expression. Returns true if the expression is false and returns false if the expression is true. If the expression (a>b) evaluates to true, then !(a>b) evaluates to false.
!(tag1 < tag2)
The expression tag1 < tag2 evaluates to true and returns a value of 1, but the NOT operator reverses the logical value, and 0 is returned.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal