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
 

 

Questions on compute verb

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
arunparameswaran

New User


Joined: 12 Oct 2007
Posts: 8
Location: Trivandrum

PostPosted: Sat Dec 15, 2007 3:27 pm    Post subject: Questions on compute verb
Reply with quote


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
View user's profile Send private message

murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Sat Dec 15, 2007 4:35 pm    Post subject:
Reply with quote

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
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Sat Dec 15, 2007 5:16 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Dec 15, 2007 11:28 pm    Post subject:
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Dec 15, 2007 11:42 pm    Post subject:
Reply with quote

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
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 ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Viewing executing process in NDM .. q... Debb.Brant IBM Tools 0 Wed Dec 14, 2016 10:55 pm
No new posts INCLUDE condition questions van bui DFSORT/ICETOOL 1 Thu Jun 30, 2016 9:52 am
No new posts SAS Programming - Basic Questions Techelm All Other Mainframe Topics 3 Fri Mar 18, 2016 10:53 pm


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