Boolean NOT 'NOT'

The Boolean NOT 'NOT' operator returns TRUE (-1) if the operand is FALSE (0), or returns FALSE (0) if the operand is TRUE (non-zero). Boolean NOT can be used in both variable and constant expressions. Example:

X := NOT Y

The above example returns the Boolean opposite of Y; TRUE (-1) if Y is zero, or FALSE (0) if Y is non-zero. During the comparison, it promotes the value of Y to -1 if it is non-zero, making any value, other than 0, a -1, so that the comparison becomes: "If NOT true" or "If NOT false"
Quite often this operator is used in combination with other comparison operators, such as in the following example.

IF NOT ( (Y > 9) AND (Y < 21) )

This example evaluates the result of (Y > 9 AND Y < 21), and returns the Boolean opposite of the result; TRUE (-1) if Y is in the range 10 to 20, in this case.

Boolean NOT becomes an assignment operator when it is the sole operator to the left of a variable on a line by itself. For example:

NOT Flag

This would store the Boolean opposite of Flag back into Flag.

Be careful not to get Boolean NOT 'NOT' confused with Bitwise NOT'!'. Boolean NOT is for comparison purposes while Bitwise NOT is for bit manipulation (see '!' - Bitwise NOT).

Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.