BITSHIFTLEFT
functionsupportedCore SQL functionsShifts the bits for a numeric or binary expression n positions to the left.
Syntax
BITSHIFTLEFT( <expr1> , <n> )
Parameters
| Name | Required | Description |
|---|---|---|
expr1 | required | This expression must evaluate to an INTEGER value, a BINARY value, or a value of a data type that can be cast to an INTEGER value. |
n | required | The number of bits to shift by. |
Returns
Returns an INTEGER value, a BINARY value, or NULL: - When the input expression contains an INTEGER value, returns a signed 128-bit (16-byte) integer, regardless of the size or data type of the input data value. - When the input expression contains a BINARY value, returns a BINARY value. - If any argument is NULL, returns NULL.
Usage notes
- If the data type of any argument is numeric but not INTEGER (e.g. FLOAT, DECIMAL, etc.), then that argument is cast to an INTEGER value.
- If the data type of any argument is a string (e.g. VARCHAR), then the argument is cast to an INTEGER value if possible. For example, the string 12.3 is cast to 12. If the value cannot be cast to an INTEGER value, then the value is treated as NULL.
- If a signed INTEGER value is returned, and the value of the high bit changes (from 0 to 1, or from 1 to 0), the sign of the result is reversed. For example, BITSHIFTLEFT(1, 127) returns a negative number.
- If a signed INTEGER value is returned, bits that are shifted past the end of the 128-bit output value are dropped.
- The function does not implicitly cast arguments to BINARY values.