hi friends,
what is actually the meaning of declaring a variable as
01 var pic -(8)9.
what does this convention -(8)9 stand for...
help me out please..
all this means is that if you display this variable (i.e. on a report) and it has a negative value in it, the value will be prefixed by a minus symbol.
05 num-fld-neg pic s9(4) value -0012.
05 num-fld-pos pic s9(4) value 12.
BTW, you coded the field backwards, I'm sure it's just a typo, it s/b:
05 ed-fld pic -9(8).
If you moved num-fld-neg to ed-fld and displayed it, you'd see -12
If you moved num-fld-pos to ed-fld and displayed it, you'd see 12
The thing to remember is that -9(8) defines a numeric edited field. Note that the leading zeros went away and there's no + for the pos 12. Also, if you coded ed-fld
pic +9(8) a pos 12 displays as +12, a neg 12 as 12 (wouldn't want to do that but there it is).
There are many flavors of edited fields in COBOL. Look up "numeric edited" or "edited" in the index of your text.
Re: Slade's comment about getting the field backwards. It is not necessarily backwards. PIC -(8)9 is the equivalent of PIC --------9 which is a valid PICTURE clause and simply floats the minus sign.
3gm is correct, and A.C.Vishy is also correct. The leading zeros would not be suppressed in slade's example. (If they are, please tell us what compiler and platform you are using, slade.)
Also, slade, again, unless your compiler does it differently, you have the presence or absence of +/- backwards:
This is from the IBM COBOL Manual:
Editing Symbol Result: Result:
in PICTURE Data Item Data Item
Character-String Positive or Zero Negative
+ + -
- space -
Note that if + is used in the picture string, you get whichever sign is appropriate. If the - sign is used in the picture string, a sign is displayed ONLY if it is NEGATIVE!
Stephen J Spiro
Member, J4 COBOL Standards Committee
check it out at
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.