MySQL bit operations

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.