by Robert Sample » Wed Feb 24, 2010 6:00 pm
Read up in the COBOL manual about the internal representation of numeric data. A PIC S9(2) USAGE DISPLAY variable (which is what you've defined -- the USAGE DISPLAY is implied if you don't specify any other USAGE clause) has two bytes with the sign stored in the second byte as the first four bits (C or x'1100' for positive, D or x'1101' for negative). After you move -21 to AA, the hex value is 'F2D1'. Adding 10 to the value makes the hex value 'F1D1'. When you display the value, a D1 in the collating sequence is a J -- so the display is 1J.