ROTATE [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Reference Manual
ROTATE
The ROTATE function returns the result of moving each bit of a number a
specified number of bits. If the number of bits to be moved is positive,
the bits move toward the right and if negative, the bits move left. If a
bit is rotated past the last bit in the number, it is placed at the other
end of the number. That is, the bits wrap around.
Syntax
ROTATE(N1,N2)
Parameters
N1 Binary representation of the value of a numeric
expression. This is of type short integer. This is the
number whose bits are to be rotated.
N2 Binary representation of the value of a numeric
expression. This is a short integer. This parameter
specifies the number of places the bits of N1 are to be
rotated. N2 must be in the range [-32767, 32767].
Examples
The following example shows the bit layout for N1 and N2. It shows the
bit layouts for N1 after the ROTATE function.
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
ROTATE(N1,-1) 1 1 0 0 0 1 1 0 1 0 1 1 0 1 0 0
ROTATE(N1,1) 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 1
ROTATE(N1,2) 1 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0
ROTATE(N1,18) 1 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0
ROTATE(N1,4) 1 0 1 0 0 1 1 0 0 0 1 1 0 1 0 1
In the above example, note that ROTATE(N1,2)=ROTATE(N1,18) because 2=18
MOD 16.
MPE/iX 5.0 Documentation