14.6. Bitwise Functions
-
bit_count
(x, bits) → bigint Count the number of bits set in
x
(treated asbits
-bit signed integer) 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
-
bitwise_and
(x, y) → bigint Returns the bitwise AND of
x
andy
in 2’s complement arithmetic.
-
bitwise_not
(x) → bigint Returns the bitwise NOT of
x
in 2’s complement arithmetic.
-
bitwise_or
(x, y) → bigint Returns the bitwise OR of
x
andy
in 2’s complement arithmetic.
-
bitwise_xor
(x, y) → bigint Returns the bitwise XOR of
x
andy
in 2’s complement arithmetic.