Comp and Comp-3

In real time in which situations we can use comp-3 and comp. What is the major difference between these two?

Questions by ajy_vjy

Showing Answers 1 - 12 of 12 Answers

Whwn USAGE is specified as COMP,the numeric data item is represented in pure binary.The item must be an integer.no assumed decimal point is allowed.
COMP item should not contain any characters other than 9,S
size:half word,full word,binary word. e.g 02 ws-var picx(04) USAGE COMP.


Where as in COMP-3 data is stored in d form of packed decimal.i.e two digit will occupy 1 byte.

  Was this answer useful?  Yes

Comp-3 is more efficient than Comp.

Comp: Binary representation of data, can contain only S, 9
1 - 4 : 2 bytes (1/2 word)
5 - 9 : 4 bytes (Full word)
10 -18 : Doubleword

Comp-3 : Packed decimal representation, two digits are stored in each byte.
n/2 + 1

Comp-3 fails at word boundaries. In this case comp is the best.
Example - 9(4)
COMP-3 : 4/2 + 1 = 3 Bytes
COMP : 2 Bytes
so in this case at word boundaries, use Comp

  Was this answer useful?  Yes

In COMP the data is stored in binary format, and displayed in character format.
In COMP3, the data is stored as the above formula.
For lower bound values COMP is best and for upper bound values COMP3 is better.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions