Bit Operations Prior to MySQL 8.0 In MySQL 8.0, bit functions and operators permit binary string type arguments ( BINARY ,  VARBINARY , and the  BLOB  types) and return a value of like type, which enables them to take arguments and produce return values larger than 64 bits. Nonbinary string arguments are converted to  BIGINT  and processed as such, as before. An implication of this change in behavior is that bit operations on binary string arguments might produce a different result in MySQL 8.0 than in 5.7. For information about how to prepare in MySQL 5.7 for potential incompatibilities between MySQL 5.7 and 8.0, see Bit Functions and Operators, in MySQL 5.7 Reference Manual. •Bit Operations Prior to MySQL 8.0 •Bit Operations in MySQL 8.0 •Binary String Bit-Operation Examples •Bitwise AND, OR, and XOR Operations •Bitwise Complement and Shift Operations •BIT_COUNT() Operations •BIT_AND(), BIT_OR(), and BIT_XOR() Operations •Special Handling of Hexadecimal Literals, Bit Literals, and NULL Literals •Bit-Operation Incompatibilities with MySQL 5.7 •This statement operates on numeric literals, treated as unsigned 64-bit integers: •This statement performs to-number conversions on the string arguments ( ’127’  to  127 , and so forth) before performing the same operations as the first statement and producing the same results: •This statement uses hexadecimal literals for the bit-operation arguments. MySQL by default treats hexadecimal literals as binary strings, but in numeric context evaluates them as numbers (see Section 9.1.4, “Hexadecimal Literals” ). Prior to MySQL 8.0, numeric context includes bit operations. Examples: Bit Operations Prior to MySQL 8.0 Bit operations prior to MySQL 8.0 handle only unsigned 64-bit integer argument and result values (that is, unsigned  BIGINT  values). Conversion of arguments of other types to  BIGINT  occurs as necessary. Examples: mysql>  SELECT X’7F’ | X’80’, X’80’ << 2, BIT_COUNT(X’0F’); mysql>  SELECT 127 | 128, 128 << 2, BIT_COUNT(15); +-----------+----------+---------------+ | 127 | 128 | 128 << 2 | BIT_COUNT(15) | +-----------+----------+---------------+ | 255 | 512 | 4 | +-----------+----------+---------------+ mysql>  SELECT ’127’ | ’128’, ’128’ << 2, BIT_COUNT(’15’); +---------------+------------+-----------------+ | ’127’ | ’128’ | ’128’ << 2 | BIT_COUNT(’15’) | +---------------+------------+-----------------+ | 255 | 512 | 4 | +---------------+------------+-----------------+ 2259