Is there a difference between PIC 9.9 and PIC 9V9?

Is there a difference between PIC 9.9 and PIC 9V9?

When you use PIC 9V9, COBOL assumes a decimal-point, and treats the number as a real(fractional) number with Integer-part before the decimal-pt and Fractional-part after the decimal-pt in all Arithmetic-Operations. 

When you use PIC 9.9, COBOL does not treat it like a Real(Decimal) Number. The decimal-Point is merely used for display-formatting purposes, the '.' character is simply force-inserted in between the 2-digits. It does not tell COBOL to treat the number as Decimal-number.



In the above code, COBOL treats WS-A as 2.3, but WS-B as 23, in all
arithmetic-Operations. When WS-A is displayed on the screen, it shows up as 23. WS-B shows up as 2.3, as you have forced a '.' symbol to be display between 2 and 3.



Also note that, WS-A occupies just 2-bytes of Storage space. WS-B on the other hand occupies 3-bytes of storage space, as you have force-inserted the decimal-point '.' character(which occupies 1 byte).

你可能感兴趣的:(Is there a difference between PIC 9.9 and PIC 9V9?)