Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Difference between COMP and COMP-4

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Ritesh Chopra

New User


Joined: 15 Oct 2007
Posts: 13
Location: India

PostPosted: Tue Oct 30, 2007 11:40 am    Post subject: Difference between COMP and COMP-4
Reply with quote

Can anyone please tell me what is difference between COMP and COMP-4 usage. As per my understanding both are binary. And please also mention what are the appropriate places to use them ?
Thanks in advance.
Back to top
View user's profile Send private message

agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Tue Oct 30, 2007 12:07 pm    Post subject:
Reply with quote

Your understanding is correct, both are same.
Infact 'BINARY' is another keyword to declare a COMP variable.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Tue Oct 30, 2007 12:14 pm    Post subject:
Reply with quote

In addition to Abhijit's.... go thru the prev topic-

http://ibmmainframes.com/post-16128.html
Back to top
View user's profile Send private message
Ritesh Chopra

New User


Joined: 15 Oct 2007
Posts: 13
Location: India

PostPosted: Tue Oct 30, 2007 12:18 pm    Post subject:
Reply with quote

Thanks abhijit but I have many programs which use COMP-4 specifically, I just wanted to know that why are we moving to COMP-4 if COMP is the same.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Tue Oct 30, 2007 1:09 pm    Post subject:
Reply with quote

I will try to keep this as simple as possible-

Usually DCLGEN generates COMP-4 variable declarations for smallint, int etc. from a Db2 Table.

There are two possible orders in which bytes can be stored in memory.
Either you store byte containing the MSB as the leftmost byte (Big endian) or at the rightmost byte (little endian). IBM processors use big endian and intel machines use little endian format to store numbers in memory.
Big endian machine store MSB in lower address im memory and little endian machine stores MSB in higher address in memory.
( Left and Right does not make much sense if you really think..I tend to go too much in my Electronics engineering but I must stop here. icon_smile.gif )

There is also COMP-5, which we must know to understand COMP behaviour-
COMP-5 always represents Native binary, so it will be depending upon the platform you use.Compiler flag determines whether plain
COMP was COMP-4 or COMP-5 (native).
The TRUNC(BIN) compiler option causes all binary data items (USAGE BINARY, COMP, COMP-4) to be handled as if they were declared USAGE COMP-5.

This kind of compiler option will be available across all ANSI compliant platforms which support cobol. So lets conclude saying that COMP-4 is just for ANSI compliance and there is no difference between Binary and Comp-4.
Experts, please correct /add to what I have written.
Back to top
View user's profile Send private message
Ritesh Chopra

New User


Joined: 15 Oct 2007
Posts: 13
Location: India

PostPosted: Wed Oct 31, 2007 10:16 am    Post subject:
Reply with quote

Thanks Abhijit,
I would also like to know, Is there any relevance between ( big endian, small endian) and (COMP ,COMP-4) ?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts Sticky: difference between ... DUMMY ... and ... enrico-sorichetti JCL & VSAM 0 Mon Oct 17, 2016 4:31 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us