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

5-1
Chapter 5 Functions
Introduction
HP Business BASIC/XL has a set of predefined standard functions. These
functions do not need to be defined to be called, nor is a calling
statement necessary. They can be treated like any expression. For
example, in the program below, Bnum and Cnum are assigned the return
value from the ABS function.
10 Anum = -10
20 Bnum = ABS(Anum) !Absolute value function
30 Cnum = ABS(3) !Absolute value function
40 PRINT Anum,Bnum,Cnum,ABS(-24) !Prints -10,10,3,24
The return value for each function has a specific data type. You can,
however, assign the return value to a variable of a different type, and
HP Business BASIC/XL will convert the return value to the type of the
variable that the function is assigned to.
ABS
The ABS function returns the absolute value of a number.
Syntax
ABS(
n
)
Parameters
n
The number whose absolute value is to be returned.
n
can be of any numeric type.
The return variable is the same type as
n
, except for INTEGER and SHORT
INTEGER types. INTEGER variables return a REAL number, and SHORT INTEGER
variables return an INTEGER.
Examples
10 Abs = ABS(-10) !Abs is 10
20 Abs = ABS(10) !Abs is 10
ACS
The ACS function returns the principal value of the arc cosine of a
number. The argument value will be in the range of [-1, 1]. The result
can be expressed in angular units of degrees, grads, or radians.
Syntax
ACS(
n
)
Parameters
n
The number to be evaluated.
n
is a REAL number.
The ACS function returns a REAL number.
Examples
10 A = ACS(0.5) !A = 60.00 (degrees)
20 B = ACS(0.5) !B = 66.67 (grads)
30 C = ACS(0.5) !C = 1.05 (radians)