View previous topic :: View next topic
|
Author |
Message |
nani556 Currently Banned New User
Joined: 10 Jul 2010 Posts: 7 Location: banglore
|
|
|
|
Hi all,
If comp and comp-3 variables are performing arthmetic operation then which will acess fast and Why? |
|
Back to top |
|
|
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
|