Joined: 02 Dec 2002 Posts: 1 Topics: 1 Location: India
Posted: Mon Dec 02, 2002 11:31 pm Post subject: When we need COMP,COMP-3 variables?
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
Joined: 02 Dec 2002 Posts: 151 Topics: 3 Location: Perth, Western Australia
Posted: Tue Dec 03, 2002 1:20 am Post subject:
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
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