ILE COBOL Language Reference

Mixed Functions

When the compiler handles a mixed function as fixed-point arithmetic, the result will be either integer or fixed-point with decimals (when any argument is floating-point, the function becomes a floating-point function and will follow floating-point rules). For MAX, MIN, RANGE, REM,and SUM, the outer-dmax is always equal to the inner-dmax. To determine the precision of the result returned for these functions, apply the rules for fixed-point arithmetic to each step in the algorithm used to calculate the function result.

MAX

  1. Assign the first argument to your function result.
  2. For each remaining argument:
    1. Compare the algebraic value of your function result with the argument.
    2. Assign the greater of the two to your function result.

MIN

  1. Assign the first argument to your function result.
  2. For each remaining argument:
    1. Compare the algebraic value of your function result with the argument.
    2. Assign the lesser of the two to your function result.

RANGE

  1. Use the steps for MAX to select your maximum argument.
  2. Use the steps for MIN to select your minimum argument.
  3. Subtract the minimum argument from the maximum.
  4. Assign the difference to your function result.

REM

  1. Divide argument-1 by argument-2.
  2. Remove all noninteger digits from the result of step 1.
  3. Multiply the result of step 2 by argument-2.
  4. Subtract the result of step 3 from argument-1.
  5. Assign the difference to your function result.

SUM

  1. Assign the value 0 to your function result.
  2. For each argument:
    1. Add the argument to your function result.
    2. Assign the sum to your function result.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]