This article discusses a case where using the MULTIPLE verb and the binary math package could result in incorrect values.
Problem:
If a COBOL program used the GIVING clause of the MULTIPLY statement and the destination field contained more post-decimal digits than any of the source fields, it was possible for the compiler to generate code that resulted in incorrect values being returned by the multiplication operation when using the binary math package. For example:
WORKING-STORAGE SECTION.
01 WS-NUMERIC-FIELDS.
03 A PIC SV9(3).
03 B PIC S9(3).
03 C PIC S9(3)V9(11).
PROCEDURE DIVISION.
MOVE -0.123 TO A.
MOVE 12 TO B.
MOVE 12 TO C.
MULTIPLY A BY B GIVING C.
In this example, fields A and B are the source fields and contain three post-decimal digits each. Field C is the destination field and contains eleven post-decimal fields. After executing this example code, field C should contain -1.47600000000 but contains -.01571111936 instead.
Resolution:
This behavior has been corrected by ECN-3912 in a future version. Install the future version when it becomes available.
Workaround: This behavior can be worked around by compiling with the "- -dec" compiler flag to invoke the decimal math package instead of the default binary math package.



