COMP-3/COMPUTATIONAL-3 Data

The RM/COBOL system represents COMP-3 data in packed decimal format with the least significant half-byte holding the sign.

This sign half-byte contains the following values:

Field RM Sign half-byte value (Hexadecimal)
Unsigned F
Signed, Positive B or F
Signed, Negative D

Consider the following examples:

Value Picture Clause RM Representation (Hexadecimal)
1234 PIC 9(5) COMP-3 00 23 4F
1234 PIC S9(5) COMP-3 00 23 4F
-1234 PIC S9(5) COMP-3 00 23 4D

The only requirement for conversion is that the sign half-byte has to be changed for signed positive fields to hexadecimal value C. The examples above are represented as follows:

Value Picture Clause This COBOL's Representation (Hexadecimal)
1234 PIC 9(5) COMP-3 00 23 4F
1234 PIC S9(5) COMP-3 00 23 4C
-1234 PIC S9(5) COMP-3 00 23 4D