IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

about comp-3


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Mon Sep 13, 2004 11:12 am
Reply with quote

how it will(+1234) store in the comp-3 .

01 a pic s9(4) comp-3 value +1234.
display a.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Sep 13, 2004 9:10 pm
Reply with quote

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
View user's profile Send private message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Wed Sep 15, 2004 9:36 am
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Sep 15, 2004 11:21 am
Reply with quote

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
View user's profile Send private message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Wed Sep 15, 2004 2:15 pm
Reply with quote

ok jack thanks 4 ur clarification i understood well .and -ve means negative
Back to top
View user's profile Send private message
ksivapradeep

New User


Joined: 30 Jul 2004
Posts: 95

PostPosted: Wed Sep 15, 2004 2:34 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Sep 15, 2004 10:04 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts convert alphanumeric PIC X(02) to hex... COBOL Programming 3
Search our Forums:

Back to Top