COMPUTE ROUNDED in COBOL
Posted: Wed Oct 16, 2013 3:53 pm
Hi Guys,
I have a doubt in below given code:
When I compiled the code and ran it, i got the following output:
however, when I used the same code and ran it on online COBOL compiler (available on Internet), I got a different result:
A:10
B:6.0
C:10.0
However, I will trust the results what I got using mainframe, I still want to know how the value of B and C is being calculated here. and I saw somewhere that ROUNDED has no impact on COMPUTE (I don't remember the link). So, is it true.
I have a doubt in below given code:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 99 VALUE 5.
01 B PIC 9V9 VALUE 6.
01 C PIC 99V9 VALUE 2.5.
01 D PIC 99 VALUE 3.
PROCEDURE DIVISION.
A100-SECTION SECTION.
COMPUTE A ROUNDED B C = A+B*C/D.
D DISPLAY 'A : ' A
D DISPLAY 'B : ' B
D DISPLAY 'C : ' C
.
EXIT.
STOP RUN.
WORKING-STORAGE SECTION.
01 A PIC 99 VALUE 5.
01 B PIC 9V9 VALUE 6.
01 C PIC 99V9 VALUE 2.5.
01 D PIC 99 VALUE 3.
PROCEDURE DIVISION.
A100-SECTION SECTION.
COMPUTE A ROUNDED B C = A+B*C/D.
D DISPLAY 'A : ' A
D DISPLAY 'B : ' B
D DISPLAY 'C : ' C
.
EXIT.
STOP RUN.
When I compiled the code and ran it, i got the following output:
A : 10
B : 00
C : 100
B : 00
C : 100
however, when I used the same code and ran it on online COBOL compiler (available on Internet), I got a different result:
A:10
B:6.0
C:10.0
However, I will trust the results what I got using mainframe, I still want to know how the value of B and C is being calculated here. and I saw somewhere that ROUNDED has no impact on COMPUTE (I don't remember the link). So, is it true.