Thursday, 16 May 2013

COMP and its types in COBOL

COMP .

              It is a Binary storage format. In most significant bit, Bit is on if -ve, off if +ve.
no of bytes in COMP = (n/2)
Data Length                                           Length in COBOL
S9(1) to S9(4)                                         2 bytes
S9(5) to S9(9)                                         4 bytes
S9(10) to S9(18)                                     8 bytes

For example: S9(8) COMP  occupy how many bytes. = 4 bytes

COMP-1 and COMP-2.

          COMP-1 - Single precision floating point. Uses 4  byte
          COMP-2 - Double precision floating point. Uses 8 byte.
here for COMP-1 and COMP-2 no PIC clause is given

for example: 01 WS-VAL USAGE COMP-1.
                      01 WS-VAL USAGE COMP-2.

COMP-3.

            COMP-3 is an packed decimal format.

Packed decimal format: Sign stored as a HEX value in the last nibble (4bits) of the storage.

            In COMP-3 the sign is stored in last nibble. For example if your number is +100, it stores HEX 0C in the last byte same if the number is -102 then HEX 2D.
General formula for COMP-3 is INT((n/2)+1)

for example: if S9(7) COMP-3  will take 4 bytes
here n=7 so INT((7/2)+1) = 4 byte

COMP-4.

            Same as COMP.

No comments:

Post a Comment

Expense Handler Application with advance technologies

Budget Planner  One of the application developed with Ionic 4 and Python-Flask.  Ionic 4 code:  https://github.com/logeshbuiltin/Expense...