This topic describes bitwise functions.

Function Description Example
bit_count(x, bits) → bigint Counts the number of bits set in x in two's complement. The x variable is treated as a signed integer that includes the specified number of bits.
  • 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 and y in two's complement. N/A
bitwise_not(x) → bigint Returns the bitwise NOT of x in two's complement. N/A
bitwise_or(x, y) → bigint Returns the bitwise OR of x and y in two's complement. N/A
bitwise_xor(x, y) → bigint Returns the bitwise XOR of x and y in two's complement. None