Theoretically, I studied like the end of character in comp-3 tells whether it is positive or negative value
- C - Indicates positive value
- D - Indicates negative value
Is this not applicable for new version of COBOL in mainframes?
01 WS-COMP3 PIC S9(5) COMP-3 VALUES -12.
DISPLAY WS-COMP3
OUTPUT: 0001K
For above piece of code, I am getting the end of character as K instead of D The value K is the substitution of -2 0 ==> } -1 ==> J, -2 ==> K ....
Using
DISPLAY ...with a numeric data type requires a conversion to a displayable type. The COBOL standard requires it.A typical conversion for
COMP-3is to move the data item to an equivalent displayable format. For this case,PIC S9(5) COMP-3is often converted toPIC S9(5) SIGN TRAILINGfor display.This conversion means the internally stored value will be converted so that individual digits, except the last, will be converted to displayable digits. The last will have the sign indicator changed to reflect the format for the particular implementation.
For IBM mainframes, the internal COMP-3 format for
-12is00 01 2Dand will be converted toF0 F0 F0 F1 D2which displays as0001K.Many ASCII systems will provide a slightly different result. The same internal format will be converted to
30 30 30 31 x2where thexdepends on the implementation's requirement. It may display as0001Bor0001ror some other, such asSIGN SEPARATEgiving-00012.The actual conversion for any data type done by any COBOL implementation will be documented in the language reference.
From the 2002 standard, B.1 Implementor-defined language element list,
DISPLAY statement, 14.8.10.3 General rules,