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

comp VS comp-3


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

New User


Joined: 10 Jul 2010
Posts: 7
Location: banglore

PostPosted: Wed Jul 14, 2010 3:50 pm
Reply with quote

Hi all,
If comp and comp-3 variables are performing arthmetic operation then which will acess fast and Why?
Back to top
View user's profile Send private message
Meenakshi Selvaraj

New User


Joined: 30 Oct 2009
Posts: 36
Location: Chennai

PostPosted: Wed Jul 14, 2010 4:16 pm
Reply with quote

COMP data items typically run faster for arithmetic operations than COMP-3 or DISPLAY data items.

In general, the following guidelines hold true:

When the data item is part of an arithmetic operation, specify USAGE IS COMP.
When the data item is used as a subscript, specify USAGE IS INDEX.

COMP is the equivalent of BINARY.
COMP-3 is the equivalent of PACKED-DECIMAL.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Jul 14, 2010 4:24 pm
Reply with quote

I have to wonder -- why do you ask? The z10 is fast enough that you have to do, literally, BILLIONS of arithmetic operations with a variable to detect any difference in CPU time or elapsed time when using COMP versus COMP-3.

The only time that you should be concerned with performance these days is after someone tells you that a program is taking too long. Until then, it is pretty much a waste of time to attempt to make performance improvements.

And Meenakshi's answer is not complete -- if you need more than 18 decimal digits, you must use COMP-3 (or DISPLAY) as COMP variables cannot exceed 18 digits while COMP-3 can be up to 31 digits (with a compiler option).
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 14, 2010 4:27 pm
Reply with quote

Adding to Meenakshi's reply, if your compiler supports COMP-5 (Native Binary), then define all of your COMP/BINARY fields as COMP-5.

Otherwise, depending on the size of your arithmetic data, you may need to specify the compiler option TRUNC(BIN), which is brutally inefficient. If TRUNC(BIN) is necessary, then you might as well define your COMP fields as COMP-3, because TRUNC(BIN) performs arithmetic using packed-decimal instructions, so there's no benefit.

With COMP-5, the TRUNC option is irrelevant.

Bill
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