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—use BITWISE_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 VARCHARf2 VARCHARf3 VARCHAR
110000001010

Last update at: 2026/05/26 17:22:09