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

[Solved]What's the size of s9(17)v9(2) COMP-3


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

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Mon Jul 18, 2005 8:48 pm
Reply with quote

Hi friends

Code:

 77     A     PIC   s9(17)v9(2) COMP-3


In the above code how much Bytes - A will occupy.


Thanks
Chandra
Back to top
View user's profile Send private message
anuradha

Active User


Joined: 06 Jan 2004
Posts: 247
Location: Hyderabad

PostPosted: Mon Jul 18, 2005 8:57 pm
Reply with quote

It can be calculated as (No of bytes+1)/2. Now you tell me how many bytes A will occupy.
Back to top
View user's profile Send private message
ralph_v

New User


Joined: 07 Jul 2005
Posts: 27

PostPosted: Tue Jul 19, 2005 9:34 am
Reply with quote

Is the declaration correct.
To my understanding we can store a maximum of length 18. ie.
01 A PIC S9(18) comp-3
which implies (18 / 2) + 1 =>10 bytes.

whereas in the post they have declared it as S9(17)V9(2). Is that correct ?

Correct if me if am wrong.
Back to top
View user's profile Send private message
anuradha

Active User


Joined: 06 Jan 2004
Posts: 247
Location: Hyderabad

PostPosted: Tue Jul 19, 2005 7:43 pm
Reply with quote

Yes Ralph! You are correct. I overlooked it. We can't declare more than 18 digit positions for comp-3 items.
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Wed Jul 20, 2005 9:41 am
Reply with quote

Dear Friends
So overally the formula wil be like this:

S9(n)V9(m) Comp-3 Should be----((n+m)+1)/2

Is it?

Correct if it is wrong?

Thanks
Chandra
Back to top
View user's profile Send private message
anuradha

Active User


Joined: 06 Jan 2004
Posts: 247
Location: Hyderabad

PostPosted: Wed Jul 20, 2005 9:28 pm
Reply with quote

Yes chandra! But remember you can't cross 18 digits
Back to top
View user's profile Send private message
mf_me

New User


Joined: 18 Jul 2005
Posts: 3

PostPosted: Wed Jul 20, 2005 9:43 pm
Reply with quote

is the 18 didgit limit only for comp-3 item ? or for all numeric items e.g can we define s9(18)v(2) ? if yes, what is the max that can be defined
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Wed Jul 20, 2005 9:52 pm
Reply with quote

Quote:
is the 18 didgit limit only for comp-3 item ? or for all numeric items


It is for all numeric items.......Not only for COMP-3....

Quote:
can we define s9(18)v(2)


Can not....

Quote:
what is the max that can be defined


18

Regards,

Priyesh.
Back to top
View user's profile Send private message
somasundaran_k

Active User


Joined: 03 Jun 2003
Posts: 134

PostPosted: Wed Jul 20, 2005 11:24 pm
Reply with quote

mf_me
Quote:

can we define s9(18)v(2) ? if yes, what is the max that can be defined


Using the Enterprise COBOL for z/OS or the newer OS/390 version you can define upto 31 digits for a numeric field. You have to use the ARITH(EXTEND) compiler option.
Check this link
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/2.4.5?DT=20020923143836

hth
-Som
Back to top
View user's profile Send private message
batu544

New User


Joined: 21 Jul 2005
Posts: 17
Location: bangalore

PostPosted: Thu Jul 21, 2005 6:01 pm
Reply with quote

hi everyone,

Can any body let me know which one is the correct formula to calculate the number of bytes used by a COMP-3 field.

1. (n+1)/2

2. (n/2+1)


plz let me know the correct one.
Back to top
View user's profile Send private message
vijayamadhuri

Active User


Joined: 06 Apr 2005
Posts: 180

PostPosted: Thu Jul 21, 2005 8:56 pm
Reply with quote

It's the first one
Back to top
View user's profile Send private message
shobam

New User


Joined: 18 Jul 2005
Posts: 34
Location: CN

PostPosted: Fri Jul 22, 2005 10:11 am
Reply with quote

To make the calculations easy
use (n+1) / 2 for odd numbers
and for even numbers (n/2) + 1

Please correct me if I am wrong.
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Fri Jul 22, 2005 10:18 am
Reply with quote

Hi Prasanth

The formula is like this:

FOR COMP-3 VALUES

[code] IF n IS ODD
TOTAL NO OF BYTES= (N+1)/2
ELSE
TOTAL NO OF BYTES= (N/2)+1
THANKS
Back to top
View user's profile Send private message
batu544

New User


Joined: 21 Jul 2005
Posts: 17
Location: bangalore

PostPosted: Fri Jul 22, 2005 4:46 pm
Reply with quote

thanks guys..
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 Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top