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 

When we need COMP,COMP-3 variables?

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


Joined: 02 Dec 2002
Posts: 1
Topics: 1
Location: India

PostPosted: Mon Dec 02, 2002 11:31 pm    Post subject: When we need COMP,COMP-3 variables? Reply with quote

Hi ,
When should we go for COMP,COMP-3 variables?
What advantage these variables have over Usage DISPLAY variables other than Memory size?
_________________
Thanks and Regards
Arvind
Back to top
View user's profile Send private message
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Tue Dec 03, 2002 1:20 am    Post subject: Reply with quote

Efficiency and a whole lot more,

To perform arithmetic on display fields is very poor programming practice. Underneath the covers the compiler has to pack, convert to binary, perform the operation and then convert to decimal and unpack back to display, not to mention all the load instructions. This is a very expensive process. If you were to use a display field as an array index it could cause a major bottleneck in your program. Counters and array indexes should be Comp (binary).

Comp-3 or packed decimal numbers are very useful. For example, Banking or billing systems use packed decimal because it's base 10, has excellent precision and is reliable. Floating point numbers, even with the best rounding methods are just not reliable. DB2 uses packed decimal for the internal representation of a timestamp. It's easy and efficient to just convert to character format using an edit mask. Not all programming languages and platforms support packed decimal
_________________
Dave Crayford
Back to top
View user's profile Send private message Send e-mail
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