doubt - COMP in COBOL

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
suhaniya
Member
Posts: 1
Joined: Tue Dec 04, 2007 12:25 pm

doubt - COMP in COBOL

Post by suhaniya » Tue Oct 21, 2008 4:25 pm

hi,
Can anyone clearly explain the comp in Cobol language?

Regards,
suhaniya.

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

COBOL COMP

Post by Natarajan » Tue Oct 21, 2008 4:54 pm

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.
Natarajan
Chennai

User avatar
JACK
Member
Posts: 20
Joined: Mon Jan 30, 2006 6:18 am

COMP VS COMP-3

Post by JACK » Wed Oct 22, 2008 1:18 pm

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.

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Sat Nov 22, 2008 9:28 am

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.
Regards,
Anuj

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others