Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WHAT DOES IT MEAN 1

Status
Not open for further replies.

kurup

Programmer
Jun 1, 2001
32
IN
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.
 
Hi Kurup,

A few examples may help:

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.

Regards, Jack.
 
thank u Jack and Pipk for ur help on this topic.I did some programs and got the concept correct ....
 
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.


Glenn
Brainbench MVP for COBOL
 
Hi Slade,
I don't think the leading zeroes would be supressed until we use "Z" in the pic clause. Please check it out and let us know.
 
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
and
 
Sorry, guys. I really screwed up that one. I guess the ol' memory is starting to go.

Regards, Jack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top