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

Why we will use comp-3 declaration


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jeelagahema

New User


Joined: 12 Jun 2005
Posts: 12
Location: bangalore

PostPosted: Tue Feb 28, 2006 9:55 am
Reply with quote

why we will use comp-3 declaration?
Back to top
View user's profile Send private message
jsk

New User


Joined: 20 Feb 2006
Posts: 12

PostPosted: Tue Feb 28, 2006 10:10 am
Reply with quote

Hi Jeelagahema,

COMP-3 enables the computer to store two digits in each storage position, except for the rightmost position, which holds the sign. Suppose if you move 1234567 into a field defined 9(7). In DISPLAY mode, which is default, this field will use 7 storage positions.
If you define the field with PIC 9(7) COMP-3, it will however use only four positions

12 34 56 7+

We can save a significant amount of storage by using the USAGE-COMP-3


Please correct me if I am wrong
Back to top
View user's profile Send private message
raghunathns

Active User


Joined: 08 Dec 2005
Posts: 127
Location: rochester

PostPosted: Tue Feb 28, 2006 7:09 pm
Reply with quote

you have to check the file status after each read

end of file.. do not process.. terminate program.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Mar 01, 2006 12:50 am
Reply with quote

jeelagahema,

Quote:
why we will use comp-3 declaration?


Just a subscript to what jsk posted. Along with the space savings that is present with COMP-3, it is also easier to read on a program dump than COMP or display, and it is more efficient for the processor than display. If you look at the object code produced by a arithmetic operation, you will fine that the complier converts display fields to COMP-3, does the operation and then converts back to display back to display. The hardware is designed to do the arithmetic operations with COMP-3 or COMP (binary), but not display fields.

Dave
Back to top
View user's profile Send private message
hncs

New User


Joined: 01 Mar 2006
Posts: 11

PostPosted: Thu Mar 02, 2006 4:35 pm
Reply with quote

IF WE USE COMP-3 THEN THE EFFICIENCY IS MORE. AND MORE OVER IT WILL TAKE VERY LESS MEMORY COMPARED WITH DISPLAY.

COMP-3 IS NOTHING BUT PACKED DECIMAL VALUE.

SUPPOSE IF THE FIELD SIZE IS S9(N)

IF N IS EVEN THEN IT WILL TAKE (N+2)/2 BYTES.

IF N IS ODD THEN IT WILL TAKE (N+1)/2 BYTES.

FOR EACH DIGIT IT WILL TAKE HALF BYTE AND HALF BYTE FOR SIGN.
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 Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts convert alphanumeric PIC X(02) to hex... COBOL Programming 3
Search our Forums:

Back to Top