MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

usage of comp

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
ksaravan
Beginner


Joined: 28 Jan 2004
Posts: 1
Topics: 1

PostPosted: Wed Jan 28, 2004 7:50 am    Post subject: usage of comp Reply with quote

Hi,

I heard that COMP fields are preferable to COMP-3 fields for complex calculations. Is there any reason behind this ? Can anyone elaborate on this.

thanks,
K.S
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Jan 28, 2004 8:52 am    Post subject: Reply with quote

Saravan,

The performance of the variables(comp or comp-3) depends on the type of arithmetic you are doing, and the final disposition of the results.

If your calculation is pure integer arithmetic, COMP is the best choice.
For calculation involving decimal portions (money related ), COMP-3 is the best choice.
For scientific calculation , sines, cosines, random number generation, COMP-2 is the best choice.

You can do a test for yourself. Code 2 different pgms with the same compute statement but fields defined as comp and comp-3. Add the following statement before the ID division
Code:

CBL LIST


The above parameter will produce a listing of the assembler-language expansion of your source code. Now take a look at the compiler listing after successful compilation. The compute statement which generates least instructions will answer your question.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group