Question: I have one question regarding computational fields. Which is the better one, is it comp or comp-3? Look For The Below Example :
77 A PIC 9(4) USAGE IS COMP. (USING 2 BYTES)
77 B PIC S9(4) USAGE IS COMP-3. (USING 3 BYTES)
Result : If you look in the above coding comp-3 is the better one.
77 A PIC 9(10) USAGE IS COMP. (USING 8 BYTES)
77 B PIC S9(10) USAGE IS COMP-3. (USING 6 BYTES)
Result : If you look in the above coding comp is the better one.
I want to know that which one is the better one, when
compare to the other.
77 A PIC 9(10) USAGE IS COMP. --- you said 8 bytes but this only uses 2 bytes and wastespart of one of the two it is using as you need to specfy 9(15) to access the full 2 bytes.
Which is best depends on what you are doing with it and whether you want decimal or binary numbers. If you mean which uses less space then storing in binary format using comp uses less space for any mumber bigger than 999. If you mean which is more readable when working with a program dump then comp-3 allows you to read the value directly rather than having to convert from hexadecimal.
This article written by Stephen Chapman, Felgall Pty Ltd.