NOT operator returns the 1's complement of its operand, after it has been rounded down if it is not an integer. The 1's complement of a value can be considered
-1-value. Some examples are:
NOT 0 is
NOT -1 is
NOT 5 is
NOT 5.7 is
NOT -6 is
NOT -6.2 is
Note that e.g.
NOT5 is a variable name; to use the
NOT operator without it becoming a variable name, it must be followed by a space, one of the other unary operators, or parentheses.
It is important not to confuse this (integer-only) bitwise NOT with
!, the logical NOT operator.
NOT FALSE (
NOT 0) has the logical sense of TRUE (though it is not the same value as
NOT TRUE also has the logical sense of TRUE, because the bitwise
NOT 1 is -2, and any nonzero numerical value interpreted as a logic value is considered to be TRUE. (Most programming languages, when they have to have a correspondence between numerical values and logical values, use 0 for FALSE and -1 for TRUE, precisely so that the bitwise NOT on the boolean values is the same as the logical NOT. SmileBoom decided to go a different way.)
This operator is in the unary precedence group, which is the highest. This means all unary operators are evaluated before any others, e.g. the bitwise operators, so
NOT A AND B is evaluated as
(NOT A) AND B. Since all unary operators are prefixes to their operands, they are right-associative, i.e. the rightmost ones are evaluated first.