Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How many bytes does comp-3 take?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Vedam

New User


Joined: 24 Apr 2007
Posts: 23
Location: India

PostPosted: Sun Apr 29, 2007 5:24 pm    Post subject: How many bytes does comp-3 take?
Reply with quote

Hi,

can you please let me know how many bytes will the following take? can you please explain in detail?

1. S9(12)V9(5) COMP-3
2. S9(17)V9(8) COMP-3
3. S9(18)V9(18) COMP-3

will any of these give compilation error?

Thanks in advance,
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Apr 29, 2007 9:42 pm    Post subject:
Reply with quote

Hello,

For "normal" processing the maximum number of digits is 18 (with the ARITH(EXTEND) compiler option, it may be 31).

To calculate the byte-length of a comp-3 field, start with the total number of digits and divide by 2 giving a result (discarding the remainder if any), then add 1 to the result.

So, a field with "pic s9(6) comp-3" would take 4 bytes (6/2 +1). A field with "pic s9(9) comp-3" would take 5 bytes (9/2 +1) - the .5 remainder is discarded. It does not matter if there are any decimal places - decimal places do not alter the field length, they are just another digit.

Using the above (and the Fine Manual linked to from this site), you can calculate the lengths of your fields and decide which might be valid in which condition(s).

After you do the calculations and look in the Fine Manual, let us know if you have any questions.

As a rule, always define an odd number of digits for a comp-3 item. Defining comp-3 fields with an even number of digits only leads to confusion.
Back to top
View user's profile Send private message
Vedam

New User


Joined: 24 Apr 2007
Posts: 23
Location: India

PostPosted: Sun Apr 29, 2007 11:29 pm    Post subject: Re: how many bytes does comp-3 take?
Reply with quote

Thanks a lot for this. It was relly helpful
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Apr 30, 2007 12:38 am    Post subject:
Reply with quote

You're welcome icon_smile.gif

What did you decide were your 3 answers? If you tell me yours, i'll tell you mine icon_smile.gif
Back to top
View user's profile Send private message
Vedam

New User


Joined: 24 Apr 2007
Posts: 23
Location: India

PostPosted: Mon Apr 30, 2007 4:51 pm    Post subject: Re: How many bytes does comp-3 take?
Reply with quote

I think 2 and 3 would give compilation error and the first one would take 9 bytes. please correct me if I am wrong.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Mon Apr 30, 2007 5:12 pm    Post subject:
Reply with quote

Vedam,

Good. icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Apr 30, 2007 7:24 pm    Post subject:
Reply with quote

Hello,

One clarification - depending on the ARITH compiler option setting, this
"2. S9(17)V9(8) COMP-3" may or may not compile successfully.

Normally, the EXTEND is not used, so your assessment is on target icon_smile.gif
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
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us