How to print decimal points in cobol?
Asked Answered
M

1

6

I want the data to be in decimal format in the spool. How can I print the data with decimal points. I have used

Pic 99v99

for my data-definition, but it is not showing a decimal-point in the result when I DISPLAY it.

12.34 for the value of my data is displayed as 1234

Mechanical answered 11/11, 2014 at 6:38 Comment(1)
next time you are around, don't forget to accept @petit.t's answer.Clyburn
I
6

The V in 99V99 is just an "invisible" decimal-point that sets the correct alignment for any fixed-point-operations. It has the advantage that it doesn't take up any additional memory. If you want a comma that is displayed use a PIC-clause like 99.99 which will

  • take up one more byte
  • only work with USAGE DISPLAY, not on COMP-fields

Note: When using DECIMAL-POINT IS COMMA you have to change the PIC-clause accordingly to: PIC 99,99

Incorporated answered 11/11, 2014 at 7:9 Comment(2)
I think PIC 99.99 will work with unsigned COMP variables as well. If you practice the case with a signed COMP variable, then you need to change your target variable data type to PIC -99.99.Celestial
This is not part of the question but would be interesting to consider: How about dealing with S9.9? The S is invalid with "."Kahler

© 2022 - 2024 — McMap. All rights reserved.