Sunday, December 25, 2011

COBOL: Why last digit of a numeric field displays alphabets

Assume I have an S9(3) field in COBOL, and try displaying its contents, I get values like this: 12{, 12A, 12R, ...   What do they mean? What are the actual numbers displayed?


As you could see, the sign is stored along with the least significant digit. Here is how you can interpret it:
   0   1   2   3   4   5   6   7   8   9

+  {   A   B   C   D   E   F   G   H   I

-  }   J   K   L   M   N   O   P   Q   R


Hence 12{ stands for +120, 12} stands for -120, 12A stands for +121 and 12R stands for -129.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.