Bitwise functions
bit_count
x (treated as bits-bit signed
integer) in 2’s complement representation:
bitwise_and
x and y in 2’s complement representation.
Bitwise AND of 19 (binary: 10011) and 25 (binary: 11001) results in
17 (binary: 10001):
bitwise_not
x in 2’s complement representation
(NOT x = -x - 1):
bitwise_or
x and y in 2’s complement representation.
Bitwise OR of 19 (binary: 10011) and 25 (binary: 11001) results in
27 (binary: 11011):
bitwise_xor
x and y in 2’s complement representation.
Bitwise XOR of 19 (binary: 10011) and 25 (binary: 11001) results in
10 (binary: 01010):
bitwise_left_shift
value.
Shifting 1 (binary: 001) by two bits results in 4 (binary: 00100):
5 (binary: 0101) by two bits results in 20 (binary: 010100):
value by 0 always results in the original value:
0 by a shift always results in 0:
bitwise_right_shift
value.
Shifting 8 (binary: 1000) by three bits results in 1 (binary: 001):
9 (binary: 1001) by one bit results in 4 (binary: 100):
value by 0 always results in the original value:
value by 64 or more bits results in 0:
0 by a shift always results in 0:
bitwise_right_shift_arithmetic
value.
Returns the same values as bitwise_right_shift when shifting by less than
64 bits. Shifting by 64 or more bits results in 0 for a positive and
-1 for a negative value: