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

How can I declare a WS var to move a S9(5) comp-3 value


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

New User


Joined: 08 Jun 2005
Posts: 4

PostPosted: Wed Jun 08, 2005 3:45 pm
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
senthilkumar selvaraju

New User


Joined: 30 May 2005
Posts: 16

PostPosted: Wed Jun 08, 2005 4:34 pm
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: 363
Location: Earth

PostPosted: Wed Jun 08, 2005 4:56 pm
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: 363
Location: Earth

PostPosted: Wed Jun 08, 2005 4:57 pm
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
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
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
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: 1592

PostPosted: Mon Jun 13, 2005 6:59 am
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
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 How to move the first field of each r... DFSORT/ICETOOL 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 How to move DB2 Installation HLQ DB2 4
Search our Forums:

Back to Top