BITNOT function

Syntax

BITNOT (expression [,bit#])

Description

Use the BITNOT function to return the bitwise negation of an integer specified by any numeric expression.

bit# is an expression that evaluates to the number of the bit to invert. If bit# is unspecified, BITNOT inverts each bit. It changes each bit of 1 to a bit of 0 and each bit of 0 to a bit of 1. This is equivalent to returning a value equal to the following:

(-expression)-1

If expression evaluates to the null value, null is returned. If bit# evaluates to the null value, the BITNOT function fails and the program terminates with a run-time error message.

Values that are not integers are truncated before the operation is performed.

The BITNOT operation is performed on a 32-bit twos-complement word.

Note: Differences in hardware architecture can make the use of the high-order bit non-portable.

Example

PRINT 
BITNOT(6),BITNOT(15,0),BITNOT(15,1),BITNOT(15,2)

This is the program output:

-7 14 13 11