Logical Operators

Top  Previous  Next

A logical operator compares two operands or expressions and produces a true or false condition. There are two types of logical operators: conditional and Boolean. Conditional operators compare two values or expressions. Boolean operators connect string, numeric, or logical expressions together to determine true-false logic. Operators may be combined to create complex operators.

Conditional Operators

=

Equal sign


 

<

Less than

 

>

Greater than

 

Boolean Operators

NOT

Boolean (logical) NOT

 

~

Tilde (logical NOT)

 

AND

Boolean AND

 

OR

Boolean OR

 

XOR

Boolean eXclusive OR

 

Combined operators

<>

Not equal

 

~=

Not equal

 

NOT =

Not equal

 

<=

Less than or equal to

 

=<

Less than or equal to

 

~>

Not greater than

 

NOT >

Not greater than

 

>=

Greater than or equal to

 

=>

Greater than or equal to

 

~<

Not less than

 

NOT <

Not less than

During logical evaluation, any non-zero numeric value or non-blank string value indicates a true condition, and a null (blank) string or zero numeric value indicates a false condition.

Example:

Logical Expression             Result

A = B                          True when A is equal to B

A < B                          True when A is less than B

A > B                          True when A is greater than B

A <> B, A ~= B, A NOT = B      True when A is not equal to B

A ~< B, A >= B, A NOT < B      True when A is not less than B

A ~> B, A <= B, A NOT > B      True when A is not greater than B

~ A, NOT A                     True when A is null or zero

A AND B                        True when A is true and B is true

A OR B                         True when A is true, or B is true, or both are true

A XOR B                        True when A is true or B is true, but not both.