MySQL uses BIGINT
(64-bit) arithmetic for bit operations, so
these operators have a maximum range of 64 bits.
|
mysql> SELECT 29 | 15; -> 31The result is an unsigned 64-bit integer.
&
mysql> SELECT 29 & 15; -> 13The result is an unsigned 64-bit integer.
^
mysql> SELECT 1 ^ 1; -> 0 mysql> SELECT 1 ^ 0; -> 1 mysql> SELECT 11 ^ 3; -> 8The result is an unsigned 64-bit integer.
XOR
was added in version 4.0.2.
<<
BIGINT
) number to the left:
mysql> SELECT 1 << 2; -> 4The result is an unsigned 64-bit integer.
>>
BIGINT
) number to the right:
mysql> SELECT 4 >> 2; -> 1The result is an unsigned 64-bit integer.
~
mysql> SELECT 5 & ~1; -> 4The result is an unsigned 64-bit integer.
BIT_COUNT(N)
N
:
mysql> SELECT BIT_COUNT(29); -> 4