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
 

 

comp VS comp-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: comp VS comp-3
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    Post subject: Reply to: comp VS comp-3
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: 8124
Location: East Dubuque, Illinois, USA

PostPosted: Wed Jul 14, 2010 4:24 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 14, 2010 4:27 pm    Post subject: Reply to: comp VS comp-3
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    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 Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 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
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm
No new posts SIGNED DECIMAL TO COMP-3 using cobol ... ram_vizag COBOL Programming 1 Tue Mar 01, 2016 11:32 pm


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