IBM Support

PH64935: INCORRECT ROUNDING AND TRUNCATION IN COBOL ARITHMETIC EXPRESSIONS

A fix is available

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as unreproducible in next release.

Error description

  • When floating-point data (IBM Hex Floating Format) is internally
    used for an intermediate result in arithmetic expressions, it
    can cause unexpected results for certain values. The following 2
    issues have been addressed:
    
    1) Incorrect rounding off position
    Rounding off to 33 decimal places happens for COBOL 5/6
    programs. This results in different results from COBOL 4.2/prior
    release. The rounding off to 31 decimal places should be used.
    2) Incorrect truncation
    When storing arithmetic final results, COBOL 5/6 Runtime fails
    to follow 'Alignment rules, Part 5. DATA DIVISION in COBOL
    Language Reference' for certain values.
    

Local fix

  • N/A
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED: Users of Enterprise COBOL 5 and later        *
    *                 releases running programs                    *
    *                 which use floating-point data.               *
    ****************************************************************
    * PROBLEM DESCRIPTION: #---------------------------------      *
    *                      # Issue.1                               *
    *                      #---------------------------------      *
    *                      For certain values, the NUMVAL          *
    *                      intrinsic function in COBOL 5/6         *
    *                      returns a value different               *
    *                      from COBOL 4.2 in the least             *
    *                      significant digit.                      *
    *                                                              *
    *                      #---------------------------------      *
    *                      # Issue.2                               *
    *                      #---------------------------------      *
    *                      When floating-point data is stored in   *
    *                      decimal data items, it fails to         *
    *                      follow the COBOL alignment rules        *
    *                      and results in storing non-zero values  *
    *                      where zero values are expected.         *
    *                                                              *
    *                      NEW FUNCTION.                           *
    ****************************************************************
    * RECOMMENDATION: Install the provided PTF.                    *
    ****************************************************************
    #---------------------------------
    # Issue.1
    #---------------------------------
    When floating-point data is internally stored in the extended
    precision(128-bit) floating-point format (IBM double precision
    HFP), the COBOL 5/6 Runtime rounds off a fractional number to
    33 decimal places while the COBOL 4.2 Runtime rounds it to 31
    decimal places. For certain values, this can cause a difference
    in its least significant digit.
    
    For example,
    
           CBL AR(E)
           IDENTIFICATION DIVISION.
           PROGRAM-ID. NUMVAL.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
             77 C15 PIC  9999.9999999999999999.
           Procedure division.
    
              COMPUTE C15  =
              FUNCTION NUMVAL("94384759660671573.6376").
              DISPLAY "C15: " C15.
    
    Actual output(from COBOL 5/6):
    C15: 1573.6375999999999999
    
    Expected output(from COBOL 4.2):
    C15: 1573.6376000000000000
    
    Note:
    The value "94384759660671573.6376" is internally stored in
    the IBM HFP format, representing
    94384759660671573.63759999999999994457766661071...  .
    
    #---------------------------------
    # Issue.2
    #---------------------------------
    When floating-point data ('sender') is stored to decimal data
    items ('receiver'), where the sender has more numeric digits
    than what the receiver can hold, truncation on the sender
    should happen as described in the section "Alignment rules"
    in the COBOL Language Reference. However the rules are
    not correctly honored for certain values.
    
    For details on the rules, refer to
    >COBOL Language Reference
    >> Part 5. DATA DIVISION
    >>> Alignment rules
    
    For example,
    
           CBL AR(C)
           IDENTIFICATION DIVISION.
           PROGRAM-ID. NUMVAL2.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
             01  COMP2                COMP-2.
             01  COMP3 PIC 9(13)V9(3) COMP-3.
           PROCEDURE DIVISION.
          * 11223344556677.0E+3 SENDER
               MOVE 11223344556677.0E+3  TO COMP2
               MOVE COMP2 TO COMP3.
               DISPLAY "CASE.1 COMP3: " COMP3
    
               COMPUTE COMP3 = 11223344556677.0E+3
               DISPLAY "CASE.2 COMP3: " COMP3
    
          * 11223344556677.0E+50 SENDER
               MOVE 11223344556677.0E+50 TO COMP2
               MOVE COMP2 TO COMP3.
               DISPLAY "CASE.3 COMP3: " COMP3
    
               COMPUTE COMP3 = 11223344556677.0E+50
               DISPLAY "CASE.4 COMP3: " COMP3
               GOBACK.
           END PROGRAM 'NUMVAL2'.
    
    Actual output:
    CASE.1 COMP3: 3344556676999900
    CASE.2 COMP3: 3344556676999900
    CASE.3 COMP3: 0000000000000112
    CASE.4 COMP3: 0000000000000112
    
    Expected output:
    CASE.1 COMP3: 3344556676999900
    CASE.2 COMP3: 3344556676999900
    CASE.3 COMP3: 0000000000000000
    CASE.4 COMP3: 0000000000000000
    
    COB0501T/K COB0502T/K COB0601T/K COB0602T/K COB0603T/K
    COB0604T/K
    

Problem conclusion

Temporary fix

Comments

  • Each of the issues can be found for certain values when
    the following conditions are met.
    (The conditions are not exhaustive)
    
    Issue.1:
    - COBOL is compiled with ARITH(EXTEND), and
    - NUMVAL/NUMVAL-C/NUMVAL-F with floating-point data is used
    
    Issue.2:
    - COBOL is compiled with ARITH(COMPAT), and
    - Floating-point data is used, and
    - MOVE or COMPUTE with floating-point data is used, and
    - The 'receiver' has fewer numeric digits than the 'sender',
       resulting in truncation
    
    The COBOL Runtime logic has been corrected.
    

APAR Information

  • APAR number

    PH64935

  • Reported component name

    LE ENT COBOL LI

  • Reported component ID

    568819812

  • Reported release

    7E0

  • Status

    CLOSED UR1

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2025-01-22

  • Closed date

    2025-02-25

  • Last modified date

    2025-03-04

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

    UO02241 UO02242

Modules/Macros

  • IGZCER4  IGZCEV4  IGZCJNI2 IGZLLIBV IGZXAPI  IGZXCA31 IGZXCDA
    IGZXD24  IGZXDMR  IGZXJNI2 IGZXLPIO IGZXLPKA IGZXLPKB IGZXLPKC
    IGZXLPKD IGZXLPKE IGZXLPKF IGZXLPKG IGZXPK2
    

Fix information

  • Fixed component name

    LE ENT COBOL LI

  • Fixed component ID

    568819812

Applicable component levels

  • R7D0 PSY UO02241

       UP25/03/01 P F502

  • R7E0 PSY UO02242

       UP25/03/01 P F502

Fix is available

  • Select the PTF appropriate for your component level. You will be required to sign in. Distribution on physical media is not available in all countries.

[{"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SS6SG3","label":"Enterprise COBOL for z\/OS"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7E0","Line of Business":{"code":"LOB70","label":"Z TPS"}}]

Document Information

Modified date:
04 March 2025