# How may do the following definitions occupy?(a) s(3)v99 comp-3(b) s(9)v99 comp

#### janaki

• Feb 23rd, 2006

comp usage doesnot allow decimal values

#### Culver_lake Profile Answers by Culver_lake

• Mar 18th, 2006

Poor syntax.  S9(3)V99 is correct and occupies 3 bytes. Count the number of 9's add 1 and divide by 2 rounding up if necessary. ex.

S9(7)v99.  there are 9 nines.  (9+1)/2 = 5 bytes.

S9(6)V99.  there are 8 nines  (8+1)/2 = 4.5 = 5 bytes.

binary data (COMP) has no fractions, integers only.

#### Anuja Tiwari

• Apr 5th, 2006

COMP fields are stored as binary.

9(1) to 9(4) are stored as 2 Binery.
9(5) to 9(9) are stored as 4 Binery.
9(10) to 9(18) are stored as 8 Binery.

so if your question is for S9(1)V9(2) comp, it will be in Binery form and occupy 2 bytes.

#### NarayaN

• Apr 26th, 2006

Can we generalize as follows,

S9(x)V9(y) will occupy (x+y+1)/2 bytes (Rounded to the next higher integer).

Is this for a USING COMP or COMP 3? How is the number of bytes calculated for the other?

Thanks!!

NarayaN

#### kapil vharande

• May 29th, 2006

For comp it will take bytes (n/2+1)For comp-3 it will take bytes as(n/2+1)+.5 & n is numeric charactor define in data division.

#### Rajeev Saklani

• Jul 20th, 2006

Hi,

ur question for comp and comp-3 storage

u have mentioned comp and assumed decimal v, for comp it is pure binary value and decimal is not allowed and storage formula is n/2 where n is number of 9's. For comp-3 we have (n/2 +1) where n is the no of 9's in integer and decimal parts. eg s9(3)v99 would occupy 5/2 +1 = 3 bytes.

for decimal we have comp-1 and comp-2 in halp word and fullword format

correct me if i am not right.

Rajeev saklani

Mainframe s/w engg

#### sunilrai15 Profile Answers by sunilrai15

• Aug 22nd, 2008

For s9(3)v99 comp-3.
system will take (5+1)/2 = 3bytes..

For S9(1)v99 comp.
Here system will take 2 bytes.
because we know that 1-4 range store 2bytes
5-9 store 4 bytes
10-18 store 8 bytes

#### Sireesha_alla Profile Answers by Sireesha_alla

• Mar 22nd, 2011

The formula for counting the number the bytes for packed decimal i.e Comp-3 is as follows:

(n/2)+1 bytes where n is the number of 9's .

For example ,

05  BALANCE-DUE   PIC S9(6)V99 COMP-3.

This has 8 9's  . so it will be calculated as ((8/2)+1) = 5 bytes. or in other way . (n+1)/2 = value (rounded)  For the above example : ((8+1) /2) = 4.5(rounded) = 5. Comp-3 stores two digits per byte. Hope this helps.

#### talluri Profile Answers by talluri

• Jul 27th, 2011

comp-3 will occupies 3bytes

comp doesn't allow the decimal values

Babjee talluri

#### guptavik1 Profile Answers by guptavik1

• Aug 27th, 2011

(A)
S9(3)V99 COMP-3 will occupy (N/2 +1) if N=Even and (N+1)/2 if N=Odd.
Here N=5 which is odd. Hence, No of bytes used for storage internally=3 bytes
(B)
S9(1)V99 COMP will occupy based on below method:-
9(1) to 9(4) are stored as 2 Binary.
9(5) to 9(9) are stored as 4 Binary.
9(10) to 9(18) are stored as 8 Binary.
Since here it's N=3, Thus it will occupy 2 bytes of internal storage.
Also Comp can store Decimal numbers.