Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
about comp-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: about comp-3
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm
No new posts SIGNED DECIMAL TO COMP-3 using cobol ... ram_vizag COBOL Programming 1 Tue Mar 01, 2016 11:32 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us