Numeric Results of Expression Evaluation

The datalogger’s expression evaluator evaluates an expression and returns a number. A conditional statement uses the number to decide which way to branch. The conditional statement is false if the number is 0 and true if the number is not 0. For example:

If 6 then Y=0,

is always true, Y will be set to 0 any time the conditional statement is executed.

If 0 then Y=0

is always false, Y will never be set to 0 by this conditional statement.

The expression evaluator evaluates the expression, X>=5, and returns –1, if the expression is true, and 0, if the expression is false.

W=(X>Y)

will set W equal to –1 if X>Y or will set W equal to 0 if X<=Y.

The datalogger uses –1 rather than some other non-zero number because the and and or operators are the same for logical statements and binary bitwise comparisons. The number –1 is expressed in binary with all bits equal to 1, the number 0 has all bits equal to 0. When –1 is anded with any other number the result is the other number, ensuring that if the other number is non-zero (true), the result will be non-zero.