Comp :
- COMP is 2 bytes.
- COMP is used for Binary Representation it allows only S and 9.
- COMP stores the data in the binary format.
- With COMP fields, you have to drag out a calculator and convert the hex value to find out the true value that is being used in a program.
- Memory usage is,
- s9(5)-s9(9) – 4bytes
- s9(1)-s9(4) – 2bytes
- s9(10)-s9(18) – 8bytes
Comp-3
- COMP-3 is 8 bytes.
- Comp-3 is used for Packed Decimal values it allows S 9 V mostly it is useful for Decimal Calculation Values.
- COMP-3 stores the data in the BCD(Binary Coded Decimal)format.
- It is used to avoid rounding issues that occur when binary numbers are used to represent decimal fractions.
- This is particularly vital in systems that method massive volumes of economic transactions/amounts
- Memory usage is
-
- n/2 + 1 (Even)
- n+1/2 (odd)
-
Example :
- Banking, Credit cards, etc.
Other cobol usages :
- The usage clause specifies how the data item being stored internally .If no usage clause specified , the default usage clause would Usage is display