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
  1. Assign the first argument to the function result.
  2. For each remaining argument, do the following steps:
    1. Compare the algebraic value of the function result with the argument.
    2. Assign the greater of the two to the function result.
MIN
  1. Assign the first argument to the function result.
  2. For each remaining argument, do the following steps:
    1. Compare the algebraic value of the function result with the argument.
    2. Assign the lesser of the two to the function result.
RANGE
  1. Use the steps for MAX to select the maximum argument.
  2. Use the steps for MIN to select the minimum argument.
  3. Subtract the minimum argument from the maximum.
  4. Assign the difference to the function result.
REM
  1. Divide argument one by argument two.
  2. Remove all noninteger digits from the result of step 1.
  3. Multiply the result of step 2 by argument two.
  4. Subtract the result of step 3 from argument one.
  5. Assign the difference to the function result.
SUM
  1. Assign the value 0 to the function result.
  2. For each argument, do the following steps:
    1. Add the argument to the function result.
    2. Assign the sum to the function result.