IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Difference between COMP and COMP-4


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 691
Location: Earth

PostPosted: Tue Oct 30, 2007 12:07 pm
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: 1436
Location: Bangalore,India

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

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

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
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: 691
Location: Earth

PostPosted: Tue Oct 30, 2007 1:09 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
Search our Forums:

Back to Top