You are here: Core Reference > Coding > Expressions > Logical and Bitwise Operators

Logical and Bitwise Operators

You can use the following logical and bitwise operators in your expressions:

Operator

Symbol

Meaning

Logical negation

Not

If the expression is True, the result is False.

If the expression is False, the result is True.

For numbers, 0 is false and every other number is true.

For strings, an empty string is false and strings containing characters are true.

For dates, 30-DEC-1899 is False and other dates are True.

Logical conjunction or Bitwise conjunction

And

Logical conjunction operators are used when both expressions Boolean. Bitwise conjunction operators are used when both expressions are numeric.

If one expression is Boolean and the other is numeric, the Boolean expression is converted into a number (TRUE=-1, FALSE=0).

Both Expressions are Boolean:

True And True = True

True And False = False

False And True = False

False And False = False

One or More Numeric expressions:

The And operator performs a bitwise comparison of 2 bits and sets the bit in the result as follows:

Bit in Expression 1 is 0, Bit in Expression 2 is 0, result bit is 0.

Bit in Expression 1 is 0, Bit in Expression 2 is 1, result bit is 0.

Bit in Expression 1 is 1, Bit in Expression 2 is 0, result bit is 0.

Bit in Expression 1 is 1, Bit in Expression 2 is 1, result bit is 1.

If the expression contains one Boolean expression and one numeric expression, the result is a Boolean expression that is converted into a numeric value (-1 for True and 0 for False).

Logical disjunction or Bitwise disjunction

Or

For Boolean expressions:

True OR True = True

True OR False = True

False OR True = True

False OR False = False

For Numeric expressions:

The OR operator performs a bitwise comparison of 2 bits and sets the bit in the result as follows:

Bit in Expression 1 is 0, Bit in Expression 2 is 0, result bit is 0.

Bit in Expression 1 is 0, Bit in Expression 2 is 1, result bit is 1.

Bit in Expression 1 is 1, Bit in Expression 2 is 0, result bit is 1.

Bit in Expression 1 is 1, Bit in Expression 2 is 1, result bit is 1.

Logical exclusion or Bitwise exclusion

Xor

For Boolean expressions:

True Xor True = False

True Xor False = True

False Xor True = True

False Xor False = False

For Numeric expressions:

The Xor operator performs a bitwise comparison of 2 bits and sets the bit in the result as follows:

Bit in Expression 1 is 0, Bit in Expression 2 is 0, result bit is 0.

Bit in Expression 1 is 0, Bit in Expression 2 is 1, result bit is 1.

Bit in Expression 1 is 1, Bit in Expression 2 is 0, result bit is 1.

Bit in Expression 1 is 1, Bit in Expression 2 is 1, result bit is 0.

Further Information

Arithmetic Operators

Comparison Operators.


ClearSCADA 2015 R2