COBOL - USAGE Clause - COMPUTATIONAL or COMP (binary)



Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

COBOL - USAGE Clause - COMPUTATIONAL or COMP (binary)

This is the equivalent of BINARY.
The COMPUTATIONAL phrase is synonymous with BINARY.

The COMPUTATIONAL or COMP phrase is specified for internal decimal items.
Such an item appears in storage as 2 digits per byte, with the sign contained in the 4 rightmost bits of the rightmost byte.
An internal decimal item can contain any of the digits 0 through 9 plus a sign.
If the PICTURE of an internal decimal item does not contain an S, the sign position is occupied by a bit configuration that is interpreted as positive.
Of all USAGEs, USAGE COMP is the most efficient in terms of operational performance.

For the ILE COBOL compiler, the COMPUTATIONAL phrase is synonymous with:

  • USAGE COMP-4(Binary), if option COMPASBIN is specified
  • Otherwise, PACKED-DECIMAL.

COMP is used for Binary Representation it allows only S and 9.

COMP stores the data in the binary format.

With COMP fields, you have to drag out a calculator and convert the hex value to find out the true value that is being used in a program.

    Memory usage is,

  • S9(05) - S9(09) – 4bytes
  • S9(01) - S9(04) – 2bytes
  • S9(10) - S9(18) – 8bytes


© Copyright IBM.