Search code examples
cobol

What does COMP VALUE ZERO in COBOL mean?


There is a great explanation for COMP under the following stackoverflow link: https://stackoverflow.com/a/42423487/7802354 but I still don't understand what COMP VALUE ZERO in

   77  ABC       PIC S9(4) COMP VALUE ZERO.

means. I would appreciate if someone clarifies that.


Solution

  • COMP or COMPUTATIONAL refers to the storage representation. For most implementations, it is the same as (big-endian) BINARY, for some PACKED-DECIMAL, rarely it is the same storage representation as DISPLAY. VALUE ZERO means that the initial value will be +0.

    It is similar to

    short abc = 0;
    

    in some other languages. However the PIC S9(4) limits the value to -9999 through +9999.