Bitwise Complement and Shift Operations +--------+---------------+ mysql>  SELECT _binary X’40’ | X’01’; +-----------------------+ | _binary X’40’ | X’01’ | +-----------------------+ | A | +-----------------------+ mysql>  SET @var1 = X’40’, @var2 = X’01’; mysql>  SELECT @var1 | @var2; +---------------+ | @var1 | @var2 | +---------------+ | A | +---------------+ Examples of binary-string evaluation: For  ~ ,  << , and  >>  bit operations, the result type depends on whether the bit argument is evaluated as a binary string or number: Bitwise Complement and Shift Operations For shift operations, bits shifted off the end of the value are lost without warning, regardless of the argument type. In particular, if the shift count is greater or equal to the number of bits in the bit argument, all bits in the result are 0. Examples of numeric evaluation: Examples of binary-string evaluation: mysql>  SELECT ~0, 64 << 2, X’40’ << 2; +----------------------+---------+------------+ | ~0 | 64 << 2 | X’40’ << 2 | +----------------------+---------+------------+ | 18446744073709551615 | 256 | 256 | +----------------------+---------+------------+ mysql>  SELECT HEX(_binary X’1111000022220000’ >> 16); +----------------------------------------+ | HEX(_binary X’1111000022220000’ >> 16) | +----------------------------------------+ | 0000111100002222 | +----------------------------------------+ mysql>  SELECT HEX(_binary X’1111000022220000’ << 16); +----------------------------------------+ | HEX(_binary X’1111000022220000’ << 16) | +----------------------------------------+ | 0000222200000000 | +----------------------------------------+ mysql>  SET @var1 = X’F0F0F0F0’; mysql>  SELECT HEX(~@var1); +-------------+ | HEX(~@var1) | +-------------+ 2265 •Binary-string evaluation produces a binary string of the same length as the bit argument. Numeric evaluation produces an unsigned 64-bit integer. •Binary-string evaluation occurs when the bit argument has a binary string type, and is not a hexadecimal literal, bit literal, or  NULL  literal. Numeric evaluation occurs otherwise, with argument conversion to an unsigned 64-bit integer as necessary.