SHIFT( ) function

Returns a single character string with the bits in the first character of the input value shifted to the left or right.


SHIFT(character, number_of_bits_to_left)



Character. The value to shift bits for.


Numeric. Specifies the number of bits to shift the character value. If the value is positive character is shifted to the left, and if the value is negative character is shifted to the right.




You can use this function in conjunction with the BYTE( ), CHR( ) and MASK( ) functions to isolate and move individual bits in a record.

If the value of the number_of_bits_to_left parameter is greater than 15 or less than -15 the result is binary zero, CHR(0).


Example Return value

SHIFT(CHR(22), 2)

The letter “X”, or CHR(88).

00010110 becomes 01011000

SHIFT(CHR(16), -1)

The backspace character, or CHR(8).

00010000 becomes 00001000

SHIFT(CHR(155), 5)

The grave accent character, or CHR(96).

10011011 becomes 01100000

Related reference
BYTE( ) function
CHR( ) function
MASK( ) function

(C) 2015 ACL Services Ltd. All Rights Reserved.