Hi,
If both of these have positive numbers - is PIC 9(3) same as PIC S9(3)?
PIC 9(3) vs PIC S9(3).
- Robert Sample
- Global Moderator
- Posts: 1896
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: PIC 9(3) vs PIC S9(3).
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).
Thanks Robert. Yes, i needed to know about their internal representation.
Is there some easy reference for this concept?
Is there some easy reference for this concept?
- Robert Sample
- Global Moderator
- Posts: 1896
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: PIC 9(3) vs PIC S9(3).
The Enterprise COBOL Programming Reference manual has a chapter on internal representation of data, so that should be where you start.
-
- Former Team Member
- Posts: 62
- Joined: Wed Aug 07, 2013 6:43 pm
Re: PIC 9(3) vs PIC S9(3).
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.
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.
Hope this helps,
d
d
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute