Reference Guide > TDV Support for SQL Functions > TDV-Supported Binary Functions > SHL Functions
 
SHL Functions
The SHL functions left-shift the bits of the binary representation of a number.
Sample Syntax
INT1SHL(arg1, arg2[, arg3])
Remarks
Shifts arg1 left by arg2 bits, filling with zeros on the right.
If arg3 is present, arg1 is ANDed with arg3 before being shifted.
Each left bit-shift doubles the number.
Examples
The table below shows examples of SHL. Most of the examples use INT1.
Function Input
Result
Comments
INT1SHL(1,0)
1
Arg2 is 0, so no shift takes place.
INT1SHL(1,1)
2
 
INT1SHL(3,2)
12
 
INT1SHL(3,10)
12
Arg2 is 10, the same as 2 mod 8 (the number of bits in INT1), so the result is the same as INT1SHL(3,2).
INT1SHL(27,1,14)
20
Arg3 is present. 27 (0001 1011) is ANDed with 14 (0000 1110), with result 10 (0000 1010). Shifted left 1, it becomes 20 (0001 0100).
INT1SHL(127,1)
 
 
INT2SHL(127,17)
 
 
INT1SHL(-2,1)
 
 
INT1SHL(-127,0)
 
 
INT1SHL(-127,1)
2
 
INT1SHL(-128,0)
0
 
INT2SHL(-128,0)