Bitwise XOR
All functions > BITWISE > Bitwise XOR
Returns the bitwise XOR (exclusive OR) of two bitstrings.
Syntax
BITWISE_XOR(left, right)
Notes
- Both operands must have the same length
- Each bit position is XORed independently: different bits = 1, same bits = 0
- XOR is its own inverse: BITWISE_XOR(BITWISE_XOR(a, b), b) = a for the same-length bitstrings a, b
- Returns NULL if either input is NULL
- The
^token is numeric exponentiation in FeatureQL, not bitstring XOR—useBITWISE_XOR
Related Functions
Examples
FeatureQL
SELECT
f1 := BITWISE_XOR('1010'::BITSTRING, '0110'::BITSTRING)::VARCHAR, -- Different bits become 1
f2 := BITWISE_XOR('1111'::BITSTRING, '1111'::BITSTRING)::VARCHAR, -- Same bits cancel out
f3 := BITWISE_XOR('1010'::BITSTRING, '0000'::BITSTRING)::VARCHAR -- XOR with zero preserves bits
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| 1100 | 0000 | 1010 |
On this page