The 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 -1

NOT -1 is 0

NOT 5 is -6

NOT 5.7 is -6

NOT -6 is 5

NOT -6.2 is 6

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 TRUE, 1), 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.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.