BIT_NOT
All functions > BITWISE > BIT_NOT
Returns the bitwise NOT (complement) of a bitstring, flipping every bit.
Signatures
Returns: Bitwise complement with all bits flipped
BIT_NOT(bitstring: BITSTRING) → BITSTRING sql
| Parameter | Type | Required | Description |
|---|---|---|---|
bitstring | BITSTRING | Yes | Bitstring to invert |
Notes
- Every 0 becomes 1 and every 1 becomes 0
- The length of the result is the same as the input
- Returns NULL if the input is NULL
Examples
FeatureQL
SELECT
f1 := BIT_NOT('1010'::BITSTRING)::VARCHAR, -- Flip all bits
f2 := BIT_NOT('0000'::BITSTRING)::VARCHAR, -- All zeros become all ones
f3 := BIT_NOT('1111'::BITSTRING)::VARCHAR -- All ones become all zeros
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| 0101 | 1111 | 0000 |
On this page