BITWISE_XOR()

All functions > BITWISE > BITWISE_XOR()

Returns the bitwise XOR (exclusive OR) of two bitstrings.

Signatures

Returns: Result bitstring, or NULL if either operand is NULL

BITWISE_XOR(left: BITSTRING, right: BITSTRING) → BITSTRING
sql
ParameterTypeRequiredDescription
leftBITSTRINGYesLeft operand
rightBITSTRINGYesRight operand

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 operators

Examples

FeatureQL
SELECT
    f1 := BITWISE_XOR('1010'::BITSTRING, '0110'::BITSTRING)::VARCHAR -- Different bits become 1
;
Result
f1 VARCHAR
1100

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