HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)
3- 25
| MOD | Binary | Modulus | 37 MOD 4=1 |
||| | |
---------------------------------------------------------------------------------------------
||| | |
| ^ | Binary | Exponentiation | 2^3=8 |
||| | |
---------------------------------------------------------------------------------------------
||| | |
| ** | Binary | Exponentiation | 2**3=8 |
||| | |
---------------------------------------------------------------------------------------------
||| | |
| MIN | Binary | Minimum | 5 MIN 4=4 |
||| | |
---------------------------------------------------------------------------------------------
||| | |
| MAX | Binary | Maximum | 5 MAX 4=5 |
||| | |
---------------------------------------------------------------------------------------------
The result of real division is of the default numeric type. The result
of integer division is truncated to a whole number. If the result is
within range, the type is integer. Otherwise, it is decimal or real.
Examples
The following examples show the results of division on different data
types:
3 DIV 2 = 1 -10 DIV 5 = -2 9.999999999 DIV 1 = 9
3/2 = 1.5 -10/5 = -2 9.999999999/1 = 9.999999999
The result of the operation
num_expr1
MOD
num_expr2
is
num_expr1
-(
num_expr2
*INT(
num_expr1
/
num_expr2
))
where INT(
x
) returns the largest integer less than or equal to
x
, for
any numeric expression
x
. By definition,
x
MOD 0 =
x
for any numeric
expression
x
. The result of the MOD operation is of the default numeric
type, DECIMAL or REAL.
Examples
The following are examples of the result of the MOD statement. Each
example shows the math required to determine the result.
38 MOD 6 = 38 - (6*INT(38/6))
= 38 - (6*6)
= 38 - 36
= 2
13 MOD -2 = 13 - (-2*INT(13/-2))
= 13 - (-2*-7)
= 13 - 14
= -1
-13 MOD 2 = -13 - (2*INT(-13/2))
= -13 - (2*-7)