cobol2.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
FP-ROUNDING Details (↑ Choosing Run-Time Behavior)
 Key Summary                             Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
     In OS/VS COBOL and VS COBOL II, if any of the sending data items of an
     arithmetic statement are floating point, all receiving fields are
     rounded, regardless of the presence or absence of the ROUNDED phrase
     and regardless of whether or not the receiving fields are floating
     point.
 
     In VS COBOL II, if any receiving data item is defined as floating
     point, rounding takes place for all receiving data items regardless of
     the presence or absence of the ROUNDED phrase, of whether or not the
     receiving field is floating point, and of whether or not there are
     any sending items which are floating point.
 
     With NO-FPROUNDING, no rounding takes place for fixed point targets in
     calculations involving floating point operands unless the ROUNDED
     phrase is explicitly used in the source.
 
     Example:
 
     If two data items are defined as follows:
 
       05 numeric-field    PIC 999.
       05 floating-field   COMP-1.
 
     and the following statement is executed:
 
       COMPUTE numeric-field floating-field = 7.7 + 1
 
     specifying FP-ROUNDING "VSC2" results in numeric-field containing
     9 (rounded), whereas specifying NOFP-ROUNDING or FP-ROUNDING "OSVS"
     would result in numeric-field containing 8 (truncated).
 
     If, using the same two data items, the following statement is
     executed:
 
       COMPUTE numeric-field = +7.6E0
 
     specifying FP-ROUNDING "VSC2" or FP-ROUNDING "OSVS" results in
     numeric-field containing 8 (rounded), whereas specifying NOFP-ROUNDING
     results in numeric-field containing 7 (truncated).
                                    -♦-