Comp variables popularly use in all mainframe technologies – COBOL/IMSDB/IMSDC/CICS. At word boundaries Comp-1 and Comp-2 are more efficient than comp-3 (takes less space).
COMP
Below is the range for “COMP” data type.
PIC 9(1) -- PIC 9(4) 2 bytes
PIC 9(5) -- PIC 9(9) 4 bytes
PIC 9(10) -- PIC 9(18) 8 bytes
COMP-1 and COMP-2
Let us take on “COMP-1”. It stores data internally as 1 word. It takes 4 bytes of space.
For Comp-2, the data stores internally as 2 words. So it takes 8 bytes. This is the reason Comp-2 is more precession than Comp-1.
The other point is, we should not specify PIC for Comp-1 and Comp-2, the reason is, the data type(numeric) and sizes (4 or 8 bytes) are pre-determined. So PIC is not required. PIC clause determines relation between data name and data-type.
Bottom Line:
Comp-1 take 4 bytes (1 word) is single precession & Comp-2 takes 8-bytes(2 words) is double precession. Here is data representation for Comp-1 and Comp-2.
05 DATA-ONE COMP-1.
05 DATA-TWO COMP-2.
Related Posts