Bitwise NOT '!'

The Bitwise NOT '!' operator performs a bitwise NOT (inverse, or one's-complement) of the bits of the operand that follows it. Bitwise NOT can be used in both variable and integer constant expressions, but not in floating-point constant expressions. 

Each bit of the two operands is subject to the following logic:

Bitwise NOT Truth Table

A

Result

0

1

1

0

Example:

X := !%00101100

The above example NOTs %00101100 and writes the result, %11010011, to X.

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

!Flag

This would store the inverted value Flag back into Flag.

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

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