View previous topic :: View next topic
|
Author |
Message |
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
how it will(+1234) store in the comp-3 .
01 a pic s9(4) comp-3 value +1234.
display a. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi K,
If you looked at the field in a dump you would see X'01234C'. BTW you should always define COMP-3 fields with an odd number of "9"s.
The field will DISPLAY as "01234{". The DISPLAY verb UNPACKs the field. If you turned HEX ON when you viewed the SYSOUT, you'd see
X'F0F1F2F3C4'. C4 displays as "{".
If the field was negative you'd see X'01234D' in the dump and it would DISPLAY as "01234}", X'F0F1F2F3D4'. |
|
Back to top |
|
|
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
ok jack,but i am getting 123N for -ve value (-1234) then why it shouldnt do unpack and display as 1234.
regards
siva pradeep |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Siva,
My apologies, I really messed up that post. I'm resending it with the corrections below.
If you looked at the field in a dump you would see X'01234C'. BTW you should always define COMP-3 fields with an odd number of "9"s.
The field will DISPLAY as "0123D". The DISPLAY verb UNPACKs the field. If you turned HEX ON when you viewed the SYSOUT, you'd see
X'F0F1F2F3C4'. C4 displays as "D".
If the field was negative you'd see X'01234D' in the dump and it would DISPLAY as "0123M", X'F0F1F2F3D4'.
Sorry for the confusion.
You said in your latest reply that you got "123N" when you displayed a packed -1234. I calculated that you should have gotten a "0123M". Could that have been a typo?
You ask:
Quote: |
then why it shouldnt do unpack and display as 1234. |
I assume you mean "why 123M and not 1234?". The answer is that UNPACK takes the last digit and the sign in a packed field and reverses them when performing the UNPACK. All other digits in the field are converted to Fn, where n is the original packed 4 bit digit. So, that means that 4C (the last digit and sign of the positive number) becomes C4 and 4D (the last digit and sign of the negative number) becomes D4 and they display as D and M respectively.
BTW, what does "-ve" mean? |
|
Back to top |
|
|
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
ok jack thanks 4 ur clarification i understood well .and -ve means negative |
|
Back to top |
|
|
ksivapradeep
New User
Joined: 30 Jul 2004 Posts: 95
|
|
|
|
hi jack i got 1 doubt that ,actually the display will reverses and takes the actual length 4m the comp-3 bu why its displaying 123n if we store -1234
regards
siva pradeep |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Siva,
You ask:
Quote: |
why its displaying 123n if we store -1234 |
The ans. is "that's the way IBM does it." If you want to display it as -1234 you have to move it to a field defined as "PIC ----9" or PIC S9999 SIGN IS LEADING SEPARATE and DISPLAY that field.
Check my syntax before trying this. |
|
Back to top |
|
|
|