View previous topic :: View next topic
|
Author |
Message |
Allu
New User
Joined: 08 Jun 2005 Posts: 4
|
|
|
|
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 |
|
|
senthilkumar selvaraju
New User
Joined: 30 May 2005 Posts: 16
|
|
|
|
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 |
|
|
subhasis_50
Moderator
Joined: 09 Mar 2005 Posts: 363 Location: Earth
|
|
|
|
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 |
|
|
subhasis_50
Moderator
Joined: 09 Mar 2005 Posts: 363 Location: Earth
|
|
|
|
Hi,
For ODD digit it is (N+1/2). |
|
Back to top |
|
|
muraly Currently Banned New User
Joined: 02 Jun 2005 Posts: 2 Location: chennai
|
|
|
|
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 |
|
|
srinivasareddy_80
New User
Joined: 07 Mar 2005 Posts: 4 Location: Chennai
|
|
|
|
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 |
|
|
srinivasareddy_80
New User
Joined: 07 Mar 2005 Posts: 4 Location: Chennai
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
|