OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
- New Member
- Posts: 2
- Joined: Sat Nov 22, 2014 10:00 pm
Please see this:
Code: Select all
05 WS-A PIC S9(9) COMP-3.
05 WS-B PIC 9(9).99.
MOVE 0.4012 TO WS-A.
MOVE WS-A TO WS-B.
DISPLAY "A to B: " WS-B.
Should not the output be 0000000000.40?
- Global Moderator
- Posts: 1288
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
No, the output is what it should be. Moving 0.4012 to WS-A changes the value to zero. Why? Because A has no decimal digits (if not specified, the decimal point is to the RIGHT of the last digit in a PICTURE). Hence the .4012 gets discarded and the value moved to WS-B is 0.
Update: your output does not match the PICTURE clause, too. Your output has 10 digits before the decimal point but WS-B is defined with 9 digits before the decimal point. If you want to post output, post the ACTUAL output, not whatever you interpret the output to be -- many times, your interpretation may not be right and you lose critical information by editing the output (such as adding an extra digits to the output).