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

5- 34
Examples
10 A = SGN(-239) !A = -1
20 B = SGN(9-(3*3)) !B = 0
30 C = SGN(78.8) !C = 1
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
SIN
The SIN function returns the sine of a number. The result can be
expressed in angular units of degrees, grads, or radians. The result is
of type REAL.
Syntax
SIN(
n
)
Parameters
n
The number to be evaluated. This is of type REAL.
Examples
10 A = SIN(60) !A = .87 (Degrees)
20 B = SIN(60) !B = .81 (Grads)
30 C = SIN(60) !C = -.30 (Radians)
SINTEGER
The SINTEGER function converts a number to a short integer. The result
is of type SHORT INTEGER.
Syntax
SINTEGER(
n
)