Description
Performs a bitwise NOT operation (one’s complement) on an integer, inverting all bits.Syntax
Parameters
Returns
Type: number (integer) The result of the bitwise NOT operation (one’s complement).Examples
Example 1: Basic NOT Operation
Example 2: Inverting All Bits
Example 3: Double NOT Returns Original
Notes
- Operates on 32-bit signed integers in JavaScript
- Result uses two’s complement representation
- NOT operation inverts all bits including sign bit
- Formula:
~n = -(n + 1) - Less commonly used than AND, OR, XOR in typical applications
See Also
- bitwise.and - Bitwise AND operation
- bitwise.or - Bitwise OR operation
- bitwise.xor - Bitwise XOR operation
Frequently Asked Questions
What does flex.bitwise.not do?
What does flex.bitwise.not do?
It performs a bitwise NOT (one’s complement) operation, flipping every bit in the integer — 0s become 1s and 1s become 0s.
Why does bitwise.not return a negative number?
Why does bitwise.not return a negative number?
Because integers use two’s complement representation. Flipping all bits of a positive number produces its negative complement minus one. For example,
flex.bitwise.not(5) returns -6.