Robert Sample wrote:Since you first gave 25, the final three bytes of the variable are filled with spaces.
Uderlying the original question was "way is my numeric field left-justified and spaced-padded not right-justified and zero filled"?
Robert Sample wrote:In doing the internal arithmetic, COBOL converts the space (hex '40') to a zero (hex 'F0') and that's why your 25 became 25000.
How and why? Because COBOL doesn't do that.
For instance, Pumpkin, try your program again with the numeric fields (I'm not going to mind about anyone calling them variables, apart from potential confusion with languages that have strings) defined as PIC S9(5). Tell us what happens. Hint, the answer is S0C7.
This is not a side-effect of ACCEPT. This is how COBOL works day-in-day-out. Anyone can try it. Define a "PIC X(5) VALUE "25"". Move that to a "PIC 9(5)" and a "PIC S9(5)". Display both the numeric items. Do some arithmetic with the first item (as in "elementary item" or "data item", we still have lots of words and phrases) (like add zero to it) and display the result. Now try with the second item. Poof. You can code the display of the result if you like, it won't get there.