View previous topic :: View next topic
|
Author |
Message |
suresh Reddy allampati
New User
Joined: 15 Sep 2005 Posts: 2 Location: pune
|
|
|
|
I want to know , in arthemetic calculations which one is faster
Either ADD or COMPUTE?
Which one is preferble ? when ?
please rectify my doubt. |
|
Back to top |
|
|
michaelraj
New User
Joined: 01 Sep 2005 Posts: 43 Location: Bangalore
|
|
|
|
Hi Suresh,
I can not exactly say which one is faster. But I can say to prefer COMPUTE. As in COMPUTE we can control through ON SIZE phrase, if the destination field is overflowed by any chance. I think it is not possible by ADD.
Regards,
Mike. |
|
Back to top |
|
|
prasanth_thavva
New User
Joined: 28 Jul 2005 Posts: 86 Location: Chennai
|
|
|
|
hi
Quote: |
Add is faster than compute |
if any wrong plz correct me
bye all d best |
|
Back to top |
|
|
amalli
New User
Joined: 06 Sep 2005 Posts: 17
|
|
|
|
hi prasanth
why add is faster then compute? give resons...........
thnaks
malli |
|
Back to top |
|
|
suresh Reddy allampati
New User
Joined: 15 Sep 2005 Posts: 2 Location: pune
|
|
|
|
Hi prasanth,
Thank u . But how it is fast, it is one of the interw question.
plz tell me the cause
suresh
prasanth_thavva wrote: |
hi
Quote: |
Add is faster than compute |
if any wrong plz correct me
bye all d best |
|
|
Back to top |
|
|
Sridevi_C
Active User
Joined: 22 Sep 2005 Posts: 104 Location: Concord, New Hampshire, USA.
|
|
|
|
michaelraj wrote: |
Hi Suresh,
I can not exactly say which one is faster. But I can say to prefer COMPUTE. As in COMPUTE we can control through ON SIZE phrase, if the destination field is overflowed by any chance. I think it is not possible by ADD.
Regards,
Mike. |
Hi,
ON SIZE phrase can be used with any arithmetic verb like ADD,SUBTRACT,MULTIPLY & DIVIDE,in the same way as it is used in COMPUTE.
ADD should be faster.Because it always refers to addition operation and so internal implementation would direct for addition immediately and move the result to destination.
In case of COMPUTE, any operation-add,subtract,multiply,divide and/or exponent can be done.So internally it would take some time to check for the type of operation to be performed and then addition operation would be selected and finally the result is moved to destination.So COMPUTE must be slow when compared to ADD.
Do correct me for any mistake(s).
Thanks!
Sridevi. |
|
Back to top |
|
|
Hames
New User
Joined: 03 Oct 2005 Posts: 49
|
|
|
|
Hi,
Sridevi's point is correct!
ADD is only a single operation Where as COMPUTE will normally contain more than one operation. So logically COMPUTE will take more time. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
The best way to determine which is "faster" is to put add and compute in a pgm and compile it w/the "list,nooff" options. Then check the Assembler code generated by each. The one w/the least code generated will be the faster of the 2.
BTW, the checking mentioned in earlier posts will be done at compile time, when the Assembler code is generated, not at execution, so no exec time will be spent on checking. |
|
Back to top |
|
|
Sridevi_C
Active User
Joined: 22 Sep 2005 Posts: 104 Location: Concord, New Hampshire, USA.
|
|
|
|
Hi Jack,
Thanks for your valuable info.
Sridevi. |
|
Back to top |
|
|
|