Skip to main content

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

Output:
(Binary: NOT 0101 = …11111010 in 32-bit two’s complement = -6)

Example 2: Inverting All Bits

Output:
(All bits become 1 in two’s complement = -1)

Example 3: Double NOT Returns Original

Output:

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

Frequently Asked Questions

It performs a bitwise NOT (one’s complement) operation, flipping every bit in the integer — 0s become 1s and 1s become 0s.
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.