Arithmetic Comparisons (Relation Conditions)

If your arithmetic is a comparison (contains a relational operator), then the numeric expressions being compared—whether they are data items, arithmetic expressions, function references, or some combination of these—are really operands (comparands) in the context of the entire evaluation. This is also true of abbreviated comparisons; although one comparand might not explicitly appear, both are operands in the comparison. When you use expressions that contain comparisons in ILE COBOL, the expression is evaluated as floating-point if at least one of the comparands is, or resolves to, floating-point; otherwise, the expression is calculated as fixed-point.

For example, consider the following statement:

    IF (A + B) = C or D = (E + F)

In the preceding example there are two comparisons, and therefore four comparands. If any of the four comparands is a floating-point value or resolves to a floating-point value, all arithmetic in the IF statement will be done in floating-point; otherwise all arithmetic will be done in fixed-point.

In the case of the EVALUATE statement:

      EVALUATE (A + D)
        WHEN (B + E) THRU C
        WHEN (F / G) THRU (H * I)
         .
         .
         .
     END-EVALUATE.

An EVALUATE statement can be rewritten into an equivalent IF statement, or series of IF statements. In this example, the equivalent IF statements are:

   if ( (A + D) >= (B + E) ) AND
      ( (A + D) <= C)
   if ( (A + D) >= (F / G) ) AND
      ( (A + D) <= (H * I) )

Thus, following these rules for the IF statement above, each IF statement’s comparands must be looked at to determine if all the arithmetic in that IF statement will be fixed-point or floating-point.



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