Page 1 of 1

doubt - COMP in COBOL

Posted: Tue Oct 21, 2008 4:25 pm
by suhaniya
hi,
Can anyone clearly explain the comp in Cobol language?

Regards,
suhaniya.

COBOL COMP

Posted: Tue Oct 21, 2008 4:54 pm
by Natarajan
Hi suhaniya,

Data item defined with COMP is represented in pure binary.
As a programmer, we need to know following.

9(1) COMP to 9(4) COMP => Occupies 2 bytes of storage
9(5) COMP to 9(9) COMP => Occupies 4 bytes of storage
9(10) COMP to 9(18 ) COMP => Occupies 8 bytes of storage.


COMP data item should not contain any character other than 9,S
Let me know, if you need any other details.

COMP VS COMP-3

Posted: Wed Oct 22, 2008 1:18 pm
by JACK
More info on COMP in COBOL.

comparison between COMP and COMP-3
- Binary format might not be suited for decimal alignment as packed
decimal format.
- Binary format is not converted to and from DISPLAY format as easily as
packed decimal format.

Posted: Sat Nov 22, 2008 9:28 am
by Anuj Dhawan
Hi,

Comp (with no suffix) leaves the choice of the data type to the compiler writer. The intent of this data type is to make it the most efficient format on any given machine, which is usually some binary format. Because of this, comp varies greatly between platforms, more than most other types.