SHIFT( ) function
Returns a single character string with the bits in the first character of the input value shifted to the left or right.
Syntax
SHIFT(character, number_of_bits_to_left)
Parameters
Name | Type | Description |
---|---|---|
character | character | The value to shift bits for. |
number_of_bits_to_left | numeric |
Specifies the number of bits to shift the character value.
If the specified value is greater than 15 or less than -15 the result is binary zero, CHR(0). |
Output
Character.
Examples
Basic examples
Returns the letter "X", or CHR(88) (00010110 becomes 01011000):
SHIFT(CHR(22), 2)
Returns the backspace character, or CHR(8) (00010000 becomes 00001000):
SHIFT(CHR(16), -1)
Returns the grave accent character, or CHR(96) (10011011 becomes 01100000):
SHIFT(CHR(155), 5)
Remarks
When to use SHIFT( )
Use the SHIFT( ) function in conjunction with the BYTE( ), CHR( ) and MASK( ) functions to isolate and move individual bits in a record.