Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
How can I declare a WS var to move a S9(5) comp-3 value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
Allu

New User


Joined: 08 Jun 2005
Posts: 4

PostPosted: Wed Jun 08, 2005 3:45 pm    Post subject: How can I declare a WS var to move a S9(5) comp-3 value
Reply with quote

Hi all,

Can any one tell me the size that I have to declare for an var in WS to display a COMP-3 var (eg:S9(5) comp-3).

Regards,
Back to top
View user's profile Send private message
References
senthilkumar selvaraju

New User


Joined: 30 May 2005
Posts: 17

PostPosted: Wed Jun 08, 2005 4:34 pm    Post subject:
Reply with quote

it takes 4 bytes( n/2 + 1)

n- number of bytes (12345 i.e 5 bytes)

1 - for sign so (5/2 + 1) = 3.5. Then it rounduped as 4 bytes.

So s9(5) comp-3 is equal to 4 bytes.
Back to top
View user's profile Send private message
subhasis_50

Moderator


Joined: 09 Mar 2005
Posts: 367
Location: Earth

PostPosted: Wed Jun 08, 2005 4:56 pm    Post subject: Re: How can I declare a WS var to move a S9(5) comp-3 value
Reply with quote

Hi,
I think it will take 3 bytes.
for example if we store +12345 in that variable, then it is internally stored as
12 34 5C
So total 3 bytes will be taken.
For even digit formula is (N/2+1)
for even digit (N+1/2)
Back to top
View user's profile Send private message
subhasis_50

Moderator


Joined: 09 Mar 2005
Posts: 367
Location: Earth

PostPosted: Wed Jun 08, 2005 4:57 pm    Post subject: Re: How can I declare a WS var to move a S9(5) comp-3 value
Reply with quote

Hi,
For ODD digit it is (N+1/2).
Back to top
View user's profile Send private message
muraly
Currently Banned

New User


Joined: 02 Jun 2005
Posts: 2
Location: chennai

PostPosted: Wed Jun 08, 2005 5:11 pm    Post subject: hi
Reply with quote

hi sentil

check u r answer

s9(5) com-3 will take 3 bites only.

why b'cos
each digit takes half byte
sign takes half byte

5 digits takes 2 1/2 bytes.
sign takes 1/2 byte.

total 3 bytes...

regards
muraly..
Back to top
View user's profile Send private message
srinivasareddy_80

New User


Joined: 07 Mar 2005
Posts: 4
Location: Chennai

PostPosted: Mon Jun 13, 2005 12:29 am    Post subject: Re: How can I declare a WS var to move a S9(5) comp-3 value
Reply with quote

Hi Friends,

we can count the size of Comp-3 field in 2 ways
1.S9(5) comp-3 It takes only N/2 1 Bytes,==>>5/2 1==>> 2.5 -.5(Remove the value which is available after Decimal point) 1==>>2 1=3 Bytes.

2.S9(5) comp-3. It is a Packed decimal, So each digit occupy 1/2 Byte 1/2 byte for sign(Right most 1/2 Byte), So 5*1/2 1/2==>>2.5 .5=3 Bytes
Back to top
View user's profile Send private message
srinivasareddy_80

New User


Joined: 07 Mar 2005
Posts: 4
Location: Chennai

PostPosted: Mon Jun 13, 2005 12:30 am    Post subject: Re: How can I declare a WS var to move a S9(5) comp-3 value
Reply with quote

Hi Friends,

we can count the size of Comp-3 field in 2 ways.


1. S9(5) comp-3 It takes only N/2 1 Bytes,==>>5/2 1==>> 2.5 -.5(Remove the value which is available after Decimal point) 1==>>2 1=3 Bytes.

2. S9(5) comp-3. It is a Packed decimal, So each digit occupy 1/2 Byte 1/2 byte for sign(Right most 1/2 Byte), So 5*1/2 1/2==>>2.5 .5=3 Bytes.


Srinivasa Reddy Lakki Reddy.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1526

PostPosted: Mon Jun 13, 2005 6:59 am    Post subject:
Reply with quote

Hi Folks,

In my opinion the best way to calc the # of bytes in a comp-3 field is to total the # of 9s. If the total is even, divide by 2; if odd add 1 then divide by 2.

It eliminates playing w/the fraction and makes the division straightforward.

Just one man's opinion.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1