Intrinsic functions evaluated in fixed-point arithmetic
The compiler determines the inner-dmax and outer-dmax values for an intrinsic function from the characteristics of the function.
Integer functions
Integer intrinsic functions return an integer; thus their outer-dmax is always zero. For those integer functions whose arguments must all be integers, the inner-dmax is thus also always zero.
The following table summarizes the inner-dmax and the precision of the function result.
Function | Inner-dmax | Digit precision of function result |
---|---|---|
DATE-OF-INTEGER | 0 | 8 |
DATE-TO-YYYYMMDD | 0 | 8 |
DAY-OF-INTEGER | 0 | 7 |
DAY-TO-YYYYDDD | 0 | 7 |
FACTORIAL | 0 | 30 in compatibility mode, 31 in extended mode |
INTEGER-OF-DATE | 0 | 7 |
INTEGER-OF-DAY | 0 | 7 |
LENGTH | n/a | 9 |
MOD | 0 | min(i1 i2) |
ORD | n/a | 3 |
ORD-MAX | 9 | |
ORD-MIN | 9 | |
YEAR-TO-YYYY | 0 | 4 |
INTEGER | For a fixed-point argument: one more digit than in the argument. For a floating-point argument: 30 in compatibility mode, 31 in extended mode. | |
INTEGER-PART | For a fixed-point argument: same number of digits as in the argument. For a floating-point argument: 30 in compatibility mode, 31 in extended mode. |
Mixed functions
A mixed intrinsic function is a function whose result type depends on the type of its arguments. A mixed function is fixed point if all of its arguments are numeric and none of its arguments is floating point. (If any argument of a mixed function is floating point, the function is evaluated with floating-point instructions and returns a floating-point result.) When a mixed function is evaluated with fixed-point arithmetic, the result is integer if all of the arguments are integer; otherwise, the result is fixed point.
For the
mixed functions MAX
, MIN
, RANGE
, REM
,
and SUM
, the outer-dmax is always
equal to the inner-dmax (and both are thus zero
if all the arguments are integer). To determine the precision of the
result returned for these functions, apply the rules for fixed-point
arithmetic and intermediate results (as referred to below) to each
step in the algorithm.
-
MAX
-
- Assign the first argument to the function result.
- For each remaining argument, do the following steps:
- Compare the algebraic value of the function result with the argument.
- Assign the greater of the two to the function result.
-
MIN
-
- Assign the first argument to the function result.
- For each remaining argument, do the following steps:
- Compare the algebraic value of the function result with the argument.
- Assign the lesser of the two to the function result.
-
RANGE
-
- Use the steps for
MAX
to select the maximum argument. - Use the steps for
MIN
to select the minimum argument. - Subtract the minimum argument from the maximum.
- Assign the difference to the function result.
- Use the steps for
-
REM
-
- Divide argument one by argument two.
- Remove all noninteger digits from the result of step 1.
- Multiply the result of step 2 by argument two.
- Subtract the result of step 3 from argument one.
- Assign the difference to the function result.
-
SUM
-
- Assign the value 0 to the function result.
- For each argument, do the following steps:
- Add the argument to the function result.
- Assign the sum to the function result.