Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print decimal points in cobol?

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

like image 364
Parthi Avatar asked Nov 11 '14 06:11

Parthi


People also ask

How do you write decimals in COBOL?

The formula for converting DECIMAL DB2 data type to COBOL equivalent is−DECIMAL(p,q) = PIC S9(p-q)V(q). Where V indicates implied decimal. The DECIMAL(7,3) can take a sample value as 7861.237 and this can be converted to COBOL equivalent as PIC S9(7-3)V(3) = PIC S9(4)V(3).

What is implicit decimal in COBOL?

Implied decimal simply means there is a decimal point implied at a specified location in a field, but not actually present in the file. For example, the number 123 with an implied decimal of two digits represents the actual value 1.23 Using implied decimal saves space in the file.

What is PIC S9 in COBOL?

PIC 9 for numbers, optionally with S (sign) or V (implicit decimal point). For example, PIC S9(7)V99 means a signed number with 7 digits to the left of the implicit decimal point and 2 digits to the right.


1 Answers

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

like image 91
piet.t Avatar answered Oct 22 '22 08:10

piet.t