The RM/COBOL system holds COMP-6 data in a similar format to COMP-3 data, except there is no sign half-byte. If a sign is indicated in the picture clause it is ignored and has no effect. The value held is always positive.
Consider the following examples:
Value | Picture Clause | RM Representation (Hexadecimal) |
---|---|---|
1234 | PIC 9(5) COMP-6 | 00 12 34 |
123456 | PIC S9(6) COMP-6 | 12 34 56 |
In order to maintain the size and capacity of the data items, this COBOL system treats COMP-6 data items as this COBOL's COMP format fields, and pads the field with binary zeros where necessary. The examples above are represented as follows:
The 9(5) COMP field is extended by one byte containing binary zero in order to maintain the size of the original item. See the section COMPUTATIONAL-6 (COMP-6) Data Types in the chapter Compatibility with RM/COBOL for details.