Purpose |
The NOT operator works as a bitwise arithmetic operator. | ||||||||

Syntax |
NOT | ||||||||

Remarks |
PowerBASIC's NOT operator returns the one's-complement
of an
PowerBASIC accepts any non-zero value as a logical TRUE value; therefore, subtle logic problems can arise in a program when the NOT operator is used to perform Boolean logic tests with operand values that are not limited to just 0 and -1. Consider the following two test conditions: test1 = 0 ' test1 is FALSE (zero) IF NOT test1 THEN ' TRUE (-1 is non-zero)
test2 = 1 ' test2 is TRUE (1 is non-zero) IF NOT test2 THEN ' still TRUE (-2 is non-zero) Because NOT performs a bitwise operation on In cases where a proper logical (Boolean) evaluation is required, and the operand may be a value other than 0 and -1, the ISFALSE operator should be used in place of the NOT operator: test3 = 1 ' test3 is TRUE (non-zero) IF ISFALSE test3 THEN ' ISFALSE detects test3 is [ The two's-complement of a value can be obtained with the following algorithm: y = (NOT x) + 1 Using NOT as a logical operator NOT returns 0 (FALSE) if
NOT performs a one's-complement or bit reversal of each bit in an integral-class value. Here is a sample: x% = NOT 16383% ' Result is -16384 | ||||||||

See also |
Arithmetic Operators, AND, EQV, IMP, ISFALSE, ISTRUE, OR, Short-circuit evaluation, XOR |