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

3- 34
Examples
4+7*2 = 4+(7*2) = 4+14 = 18
(4+7)*2 = 11*2 = 22
3-2+1 = (3-2)+1 = 1+1 = 2
3-(2+1) = 3-3 = 0
NOT A**3 MOD 12 + 75 = B AND C OR D =
(((((NOT(A**3)) MOD 12) + 75) = B) AND C) OR D
Result Type
If an arithmetic operation has two operands of the same type, the
operation is performed using that type. The intermediate result is of
that type, and an error occurs if the intermediate result is out of the
range of the final result type. The following are exceptions:
* Short integer arithmetic, performed in integer arithmetic.
* Exponentiation in which the base is converted to a real for all
types. The exponent is converted to a real for decimal, short
decimal, and short real. The exponents for integers and short
integers are not converted. That is, a short integer remains a short
integer, and an integer remains an integer.
Examples
10 INTEGER A,B
20 REAL C
30 C=A+B
99 END
In line 30 of the above program, the intermediate result of A+B is an
integer. It is converted to a real number when it is assigned to the
real variable, C.
If an arithmetic operation has two operands of different types, one or
both operands are converted to one type before the operation. The type
that they are converted to depends on the default numeric type.
Precision can be lost when numbers are converted between real and dec-
imal types. Overflow can occur when numbers are converted to a type
with a smaller range (for example, real to short real).
Subunits
A program can be divided into program units consisting of one main
program unit followed by one or more subunits. In this section, the main
program unit is called the main program.
A subunit is a series of program lines that can be called with
parameters, by another program unit. The calling program unit transfers
control to the subunit; the subunit executes and returns control to the
calling program unit. The calling program unit can be the main program
or another subunit.