HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)

5-29
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.
ROUND
The ROUND function rounds a number to a specified power of 10. The
result is of type DECIMAL.
Syntax
ROUND(
n1
[,
n2
])
Parameters
n1
The number to be rounded. This is of type DECIMAL.
n2
The power of 10 that
n1
is to be rounded to. If
n2
is
not specified, 0 is the default.
Examples
10 A = ROUND(32767,2) !A = 32800
20 B = ROUND(32067,3) !B = 32000
30 C = ROUND(5.07,0) !C = 5
40 D = ROUND(5.07) !D = 5
50 E = ROUND(5.07,-1) !E = 5.1
ROW
The ROW function returns the number of rows in an array as it is
currently dimensioned. If it is a vector (one dimensional array), the