Microsoft KB Archive/40711

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 19:22, 12 August 2020 by X010 (talk | contribs) (X010 moved page Microsoft KB Archive/Q40711 to Microsoft KB Archive/40711 without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Dividing Negative Number by Constant Gives Garbage in COBOL

PSS ID Number: Q40711 Article last modified on 11-18-1990

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

Summary: When Microsoft COBOL versions 3.00 and 3.00a divide a negative number by a constant or a Level 78 data item, the results produced may be incorrect. If the constant or Level 78 data item is replaced by a standard data item in the WORKING-STORAGE SECTION, the division works correctly. The program below demonstrates the problem. Microsoft has confirmed this to be a problem in versions 3.00 and 3.00a. This problem was corrected in Microsoft COBOL Professional Development System version 4.00 for MS-DOS and MS OS/2.

Code Example

This program should be compiled and LINKed without a COBOL.DIR file: WORKING-STORAGE SECTION. 78 REAL-CONST VALUE 2. 77 CONSTANT-1 PIC 99 VALUE 2. 77 NUMERATOR PIC S9(6)V99 VALUE 0. 77 RESULT-1 PIC S9(6)V99 VALUE 0. 77 RESULT-2 PIC S9(6)V99 VALUE 0. PROCEDURE DIVISION. MOVE -100 TO NUMERATOR. Prints correct result COMPUTE RESULT-1 = NUMERATOR / CONSTANT-1. DISPLAY RESULT-1. Prints incorrect result COMPUTE RESULT-2 = NUMERATOR / 2. DISPLAY RESULT-2. *Also prints incorrect result COMPUTE RESULT-2 = NUMERATOR / REAL-CONST. DISPLAY RESULT-2. STOP RUN.

Copyright Microsoft Corporation 1990.