Page 1 of 1
PIC 9(3) vs PIC S9(3).
Posted: Sun Jan 12, 2014 4:43 pm
by KavalJeet
Hi,
If both of these have positive numbers - is PIC 9(3) same as PIC S9(3)?
Re: PIC 9(3) vs PIC S9(3).
Posted: Sun Jan 12, 2014 7:24 pm
by Robert Sample
It depends upon what you mean by "same". If you are asking about the values, then yes both will have positive values. If you mean are the hexadecimal internal representations the same, the answer is then that they are NOT the same. PIC 9(3) is an unsigned variable so 123 would be stored as X'F1F2F3' whereas PIC S9(3) is a signed variable so 123 would be stored as X'F1F2C3'. Both would DISPLAY as 123. Information on how COBOL stores values can be found in the Language Reference manual which you should be able to access at your site.
Re: PIC 9(3) vs PIC S9(3).
Posted: Sun Mar 16, 2014 9:57 am
by KavalJeet
Thanks Robert. Yes, i needed to know about their internal representation.
Is there some easy reference for this concept?
Re: PIC 9(3) vs PIC S9(3).
Posted: Sun Mar 16, 2014 9:40 pm
by Robert Sample
The Enterprise COBOL Programming Reference manual has a chapter on internal representation of data, so that should be where you start.
Re: PIC 9(3) vs PIC S9(3).
Posted: Mon Mar 17, 2014 5:50 am
by dick scherrer
Keep in mind that while both support positive values, if the 2 definitions are in different group fields, a comparison of the 2 groups will often compare not equal.
Depends on if the value has an F sign or a C sign. . .
While reading the manual, suggest you experiment with a bit of test code.