bit_shift_left
description
syntax
BIT_SHIFT_LEFT(BIGINT x, TINYINT c)
Do logical left shift to BIGINT type x by c bits, and return result as a BIGINT. Return zero if c is less than 0.
example
Normal case
1. select 8 as x, number as c, bit_shift_left(8, number) as bit_shift_left from numbers("number"="5")
2. --------------
4. +------+------+----------------+
5. | x | c | bit_shift_left |
6. +------+------+----------------+
7. | 8 | 0 | 8 |
8. | 8 | 1 | 16 |
9. | 8 | 2 | 32 |
10. | 8 | 3 | 64 |
11. | 8 | 4 | 128 |
12. +------+------+----------------+
13. 5 rows in set (0.04 sec)
Left shift result of 9223372036854775807 which is BIGINT_MAX by 1 bit will get -2.
1. WITH tbl AS (
2. SELECT 9223372036854775807 AS BIGINT_MAX
3. )
4. SELECT BIGINT_MAX, bit_shift_left(BIGINT_MAX, 1)
5. FROM tbl
6. --------------
8. +---------------------+-------------------------------+
9. | BIGINT_MAX | bit_shift_left(BIGINT_MAX, 1) |
10. +---------------------+-------------------------------+
11. | 9223372036854775807 | -2 |
12. +---------------------+-------------------------------+
13. 1 row in set (0.05 sec)
keywords
1. BITSHIFT, BITSHIFTLEFT
