Not Operator
Language Items List
Definition:
Used to perform logical negation on a single expression.
Syntax:
result = Not expr
Details:
The Not operator, also known as the logical negation operator, examines each
bit in the supplied expression and sets the corresponding bit in result to its opposite. The following table summarizes the results:
expr bit result bit
- 0
0 1
In the case of an integer variable with a value 0, the variable becomes -1.
The variable becomes 0, in the case of an integer variable with the value of -1.
That is why True has the value -1, and False has the value 0, because:
Not True = Not -1 = 0 = False
Note: It is important when using Not to always use -1 for True, because only the
value -1 when bitwise negated yields 0, any other value such as 1, bitwise
negates to something else. In particular “Not 1” yields -2, which is not equal to False.
See Also:
Arithmetic Operators
Comparison Operators
Logical Operators
Operator Precedence
Example:
If Not False Then Print “Must be True.”
If Not True Then Print “Must be False.”