> ## Documentation Index
> Fetch the complete documentation index at: https://new.docs.falkordb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# bitwise.not

> Performs a bitwise NOT (one's complement) on an integer, inverting all bits.

## Description

Performs a bitwise NOT operation (one's complement) on an integer, inverting all bits.

## Syntax

```cypher theme={null}
flex.bitwise.not(a)
```

## Parameters

| Parameter | Type             | Required | Description           |
| --------- | ---------------- | -------- | --------------------- |
| `a`       | number (integer) | Yes      | The operand to invert |

## Returns

**Type:** number (integer)

The result of the bitwise NOT operation (one's complement).

## Examples

### Example 1: Basic NOT Operation

```cypher theme={null}
RETURN flex.bitwise.not(5) AS result
```

**Output:**

```text theme={null}
result
------
-6
```

(Binary: NOT 0101 = ...11111010 in 32-bit two's complement = -6)

### Example 2: Inverting All Bits

```cypher theme={null}
RETURN flex.bitwise.not(0) AS result
```

**Output:**

```text theme={null}
result
------
-1
```

(All bits become 1 in two's complement = -1)

### Example 3: Double NOT Returns Original

```cypher theme={null}
WITH 42 AS value
RETURN flex.bitwise.not(flex.bitwise.not(value)) AS restored
```

**Output:**

```text theme={null}
restored
--------
42
```

## 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](/udfs/flex/bitwise/and) - Bitwise AND operation
* [bitwise.or](/udfs/flex/bitwise/or) - Bitwise OR operation
* [bitwise.xor](/udfs/flex/bitwise/xor) - Bitwise XOR operation

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="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.
  </Accordion>

  <Accordion title="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`.
  </Accordion>
</AccordionGroup>
