Previous Topic Next topic Print topic


COMP/COMPUTATIONAL Data

The RM/COBOL system represents COMP (or COMPUTATIONAL) data in packed decimal format with one character per byte stored in each least significant four bits. The most significant half-byte always contains zero. If the picture string specifies a signed representation, an additional byte is added to the least significant end of the string: a negative value is represented by the hexadecimal value x"D", and a positive value is represented by the hexadecimal value x"B".

Consider the following examples:

Value Picture Clause RM Representation (Hexadecimal)
1234 PIC 9(5) COMP 00 01 02 03 04
1234 PIC S9(5) COMP 00 01 02 03 04 0B
-1234 PIC S9(5) COMP 00 01 02 03 04 0D

You should converts COMP data fields into DISPLAY format, with sign trailing separate. This is compatible with this COBOL system's treatment of RM/COBOL COMP fields in the source program when the RM directive is set. If the data item is signed, the sign byte has the most significant half-byte set to hexadecimal value 2.

After conversion, the examples above are represented as follows:

Value Picture Clause This COBOL's Representation (Hexadecimal)
1234 PIC 9(5) DISPLAY 30 31 32 33 34
1234 PIC S9(5) DISPLAY 30 31 32 33 34 2B
-1234 PIC S9(5) DISPLAY 30 31 32 33 34 2D
Previous Topic Next topic Print topic