6.7. Bitwise Functions
bitcount
(_x, bits) → bigint
Count the number of bits set inx
(treated asbits
-bit signedinteger) in 2’s complement representation:- SELECT bit_count(9, 64); -- 2
- SELECT bit_count(9, 8); -- 2
- SELECT bit_count(-7, 64); -- 62
- SELECT bit_count(-7, 8); -- 6
bitwiseand
(_x, y) → bigint
Returns the bitwise AND ofx
andy
in 2’s complement representation.
bitwisenot
(_x) → bigint
Returns the bitwise NOT ofx
in 2’s complement representation.
bitwiseor
(_x, y) → bigint
Returns the bitwise OR ofx
andy
in 2’s complement representation.
bitwisexor
(_x, y) → bigint
Returns the bitwise XOR ofx
andy
in 2’s complement representation.
See also
bitwise_and_agg()
and bitwise_or_agg()
.