SHIFT()

SHIFT()

Top  Previous  Next

 

The SHIFT() function performs a logical bit-shift operation on an integer value.

 

 

Format

 

SHIFT(value, shift.len)

 

where

 

valueevaluates to the integer to be shifted.

 

shift.lenindicates the number of bit positions by which value is to be shifted.

 

 

The SHIFT() function converts value to a thirty two bit integer, truncating any fractional part of a non-integer value, and shifts the bit pattern of this value by shift.len positions.

 

A positive value of shift.len shifts right (towards the low order end). A negative value of shift.len shifts left (towards the high order end).

 

Values of shift.len that are outside the range -32 to +32 have undefined results.

 

 

Example

 

FOR I = 30 TO 0 STEP - 3

  DISPLAY BITAND(SHIFT(N, I), 7) :

NEXT I

 

This program fragment displays the value of N in octal. The MO conversion mode of the OCONV() function would be more appropriate.

 

 

See also:

BITAND(), BITNOT(), BITOR(), BITRESET(), BITSET(), BITTEST(), BITXOR()