Page 1 of 1

Choose the correct definition of a numeric field.

Posted: Mon Nov 16, 2015 2:25 pm
by SuperRa
Hi,

The interviewer wrote this on paper

Code: Select all

05 WS-VARIABLE1 PIC S9(05)V99.
and

Code: Select all

05 WS-VARIABLE2 PIC +99999.99.
and said that I want to move +12345.67 in any of these variables. I have two choices, one I want to use the variable in the program. May be I shall use the variable for calculation and I may not. For other choice, I want to and display it I want to use the variable in the program. May be I shall use the variable for calculation and I may not but at the end of the program I want to display the variable in this choice.

Which one of the above is the correct way to define for this?

Re: Choose the correct definition of a numeric field.

Posted: Mon Nov 16, 2015 6:57 pm
by Robert Sample
WS-VARIABLE1 is a numeric variable and can be used as such in COBOL. WS-VARIABLE2 is a numeric edited variable -- which is NOT a numeric variable -- and COBOL limits what you can do with it. Numeric edited variables are used most often to display data (in a report, often).

Re: Choose the correct definition of a numeric field.

Posted: Mon Nov 16, 2015 9:57 pm
by William Collins
To get directly-human-readable (non-programmer) output and do calculation, you could do with using both.

A numeric-edited field cannot be used in calculations, but is the best way to represent output.

A numeric field can be used in calculation, but, especially when signed and having decimal places, is not easy for a non-technical person to understand.