View previous topic :: View next topic
|
Author |
Message |
arunparameswaran
New User
Joined: 12 Oct 2007 Posts: 8 Location: Trivandrum
|
|
|
|
Hi all,
Please help me to clarify the doubts on Compute usages in Arithmetic Operations.
What all are the demerits of Compute verb?
Will it make any lagging to memory storage while operation?
Which one is fastest Compute or Add?
Any difference in precision / accuracy between Compute and ADD operations?
Thanks and Regards,
Arun |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Arun,
Quote: |
Which one is fastest Compute or Add? |
Why dont 'you' some test and let us know?
Quote: |
Any difference in precision / accuracy between Compute and ADD operations? |
Precision and accuracy depends on how you 'declare' the data. |
|
Back to top |
|
|
raak
Active User
Joined: 23 May 2006 Posts: 166 Location: chennai
|
|
|
|
One of the differences is in the usage of ON SIZE ERROR command..U can use it with COMPUTE, but not with ADD... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The performance will be similar. If the calculation is complex, i'd suggest using code that will be easiest to read/maintain later. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Arun,
One of the most serious drawbacks when using COMPUTE (it's a DIVIDE problem, not an ADD problem) is its malfunctioning when using a quotient with an insufficent number of decimal places.
Here's an example of the problem:
* THE ANSWER SHOULD BE 24.8
Code: |
COMPUTE WS-PERCENT-999.9 = (248 / 1000) * 100.
COMPUTE WS-PERCENT-999.99 = (248 / 1000) * 100.
COMPUTE WS-PERCENT-999.999 = (248 / 1000) * 100.
COMPUTE WS-PERCENT-999.9999 = (248 / 1000) * 100. |
What each of the above produces:
PIC 999.9: 020.0
PIC 999.99: 024.00
PIC 999.999: 024.800
PIC 999.9999: 024.8000 |
|
Back to top |
|
|
|