Bitwise AND

All functions > BITWISE > Bitwise AND

Returns the bitwise AND of two bitstrings.

Syntax

left & right  ·  BITWISE_AND(left, right)

Notes

  • Both operands must have the same length
  • Each bit position is ANDed independently: 1 AND 1 = 1, all other combinations = 0
  • Returns NULL if either input is NULL

Related Functions

Examples

BITWISE_AND(...)

FeatureQL
SELECT
    f1 := BITWISE_AND('10101'::BITSTRING, '10001'::BITSTRING)::VARCHAR, -- AND preserves common 1-bits
    f2 := BITWISE_AND('1111'::BITSTRING, '1010'::BITSTRING)::VARCHAR, -- Masking with AND
    f3 := BITWISE_AND('1100'::BITSTRING, '0011'::BITSTRING)::VARCHAR -- No common bits
;
Result
f1 VARCHARf2 VARCHARf3 VARCHAR
1000110100000

Operator &

FeatureQL
SELECT
    f1 := ('10101'::BITSTRING & '10001'::BITSTRING)::VARCHAR, -- AND preserves common 1-bits
    f2 := ('1111'::BITSTRING & '1010'::BITSTRING)::VARCHAR, -- Masking with AND
    f3 := ('1100'::BITSTRING & '0011'::BITSTRING)::VARCHAR -- No common bits
;
Result
f1 VARCHARf2 VARCHARf3 VARCHAR
1000110100000

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