您的位置:首页 > 数据库 > MySQL

mysql 位操作

2012-05-08 17:40 169 查看
Bitwise OR:
mysql> SELECT 29 | 15;
-> 31
The result is an unsigned 64-bit integer.

&
Bitwise AND:
mysql> SELECT 29 & 15;
-> 13
The result is an unsigned 64-bit integer.

^
Bitwise XOR:
mysql> SELECT 1 ^ 1;
-> 0
mysql> SELECT 1 ^ 0;
-> 1
mysql> SELECT 11 ^ 3;
-> 8
The result is an unsigned 64-bit integer.

<<
Shifts a longlong (BIGINT) number to the left.
mysql> SELECT 1 << 2;
-> 4
The result is an unsigned 64-bit integer.

>>
Shifts a longlong (BIGINT) number to the right.
mysql> SELECT 4 >> 2;
-> 1
The result is an unsigned 64-bit integer.

~
Invert all bits.
mysql> SELECT 5 & ~1;
-> 4
The result is an unsigned 64-bit integer.

BIT_COUNT(N)
Returns the number of bits that are set in the argument N.
mysql> SELECT BIT_COUNT(29);
-> 4
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: