Not
Operator
For a Boolean expression, returns the opposite value. For an integer expression, does a bitwise NOT operation.
Syntax
Not expression
Parts
expression
- A Boolean or integer expression.
Instructions
For Boolean expressions, the table that follows shows how to calculate the result.
If expression is |
Then the result is |
---|---|
True | False |
False | True |
For numeric expressions, the result of the operator NOT
is the opposite value of each bit.
See the table that follows.
If the bit in expression is |
Then the bit in the result is |
---|---|
1 | 0 |
0 | 1 |
Note: The logical and bitwise operators have lower precedence than the arithmetic and relational operators. Thus, we recommend that you put parentheses around bitwise operations to make sure they give correct results.
Examples
Var pattern As UInt8 = %B11110000
Var inverse = Not pattern
Variable | Value |
---|---|
pattern |
240 (11110000) |
inverse |
15 (00001111) |