HP 3000 Manuals

SHIFT [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation


HP Business BASIC/XL Reference Manual

SHIFT 

The SHIFT function moves each bit of a number a specified number of
places.  If the number of places is positive, the bits move to the right,
and if negative, to the left.  If a bit is shifted out of the number, it
is dropped.

Syntax 

SHIFT(N1,N2)

Parameters 

N1               Binary representation of the value of a numeric
                 expression.  This is a short integer.  This is the
                 number whose bits are to be shifted.

N2               Binary representation of the value of a numeric
                 expression, a short integer.  This is the number that
                 specifies how many places to shift the bits.  N2 must be
                 in the range [-32767, 32767].

Examples 

The following shows the bit layout for N1, and several examples of the
SHIFT function.  Each example uses a different value for N2.

     Bit Number:    0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
     N1             0  1  1  0  0  0  1  1  0  1  0  1  1  0  1  0
     SHIFT(N1,-1)   1  1  0  0  0  1  1  0  1  0  1  1  0  1  0  0
     SHIFT(N1,1)    0  0  1  1  0  0  0  1  1  0  1  0  1  1  0  1
     SHIFT(N1,-3)   0  0  0  1  1  0  1  0  1  1  0  1  0  0  0  0
     SHIFT(N1,4)    0  0  0  0  0  1  1  0  0  0  1  1  0  1  0  1



MPE/iX 5.0 Documentation