How many bytes occupied following comp example?

Dear Friends,
This is regarding COBOL comp.
PIC X(3) occupy the 3 bytes... but PIC 9(3)V9(7) COMP occupied how much bytes?
I said in interview that 10/2 = 5 bytes. V is specified for decimal point.
Is that correct? But interviewer looked at me differently when I said this answer?
If you are more confident, please reply this ...thanks in advance,.

Questions by Josephvincent2014

Showing Answers 1 - 23 of 23 Answers


  • Oct 23rd, 2014

the length is 8 byte it is find by using LENGTH OF clause.

  Was this answer useful?  Yes


  • Nov 2nd, 2014

1-4=2 bytes
5-9=4 bytes
9 above 8 bytes
here 7+3=10+1(sign)
total 11 btes
so 8 bytes is the answer.


  • Nov 10th, 2014

yup for decimal point i.e.,each bit occupies half byte and for sing one extra half in total it occupies 10 halfbytes=5bytes...

  Was this answer useful?  Yes


  • Dec 3rd, 2014

in my view comp clause doesn't support decimal values it supports only binary values.decimal values will be supported by comp-3

  Was this answer useful?  Yes


  • Jun 11th, 2015

I believe above question will occupy 8 bytes.
As for:
1 - 4 characters - 2 bytes
5 - 9 characters - 4 bytes
10 - 18 characters - 8 bytes
There is no space occupied by decimal.
The calculation which you are doing is for COMP -3 where in each character occupies half byte or a nibble

  Was this answer useful?  Yes


  • Jul 27th, 2015

6 Bytes

  Was this answer useful?  Yes


  • Aug 12th, 2015

It occupies 10 bytes of space because no space allocated for decimal pointer v .

  Was this answer useful?  Yes


  • Aug 12th, 2015

He looked at you differently since it was a trick question. The example he gave is invalid, since COMP only stores integers, no implied decimals.

  Was this answer useful?  Yes


  • Feb 16th, 2016

8 byte because in comp 0-4 takes 2 bytes,5-9 takes 4 byte and 10-18 takes 8 byte.

  Was this answer useful?  Yes


  • Feb 18th, 2016

8 bytes.

  Was this answer useful?  Yes


  • Aug 24th, 2016

There is no such length in cobol for comp. The max length is a full-word, which means S9(08) comp. 4 bytes long. For COMP-3 you may use 10 bytes long, and for Alpha 128 M

  Was this answer useful?  Yes


  • Aug 29th, 2016

PIC S9(01) TO S9(04) C0MP =2 BYTES
PIC S9(05) TO S9(09) C0MP =4 BYTES
PIC S9(10) TO S9(18) C0MP =8 BYTES

  Was this answer useful?  Yes


  • Sep 1st, 2016

We cannot use pic clause when specifying comp usage clause...

  Was this answer useful?  Yes


  • Feb 2nd, 2017

Comp is a binary storage format and does not allow decimals. It is invalid syntax

  Was this answer useful?  Yes


  • Feb 17th, 2017

Only numeric data is specified as COMP. I have 2 points to say here:
1) PIC X(3) COMP is not valid. Hence, this is invalid
2) Picture clause in COMP can have either 9 or S and here the picture clause being S9(3)V9(7) COMP becomes invalid

  Was this answer useful?  Yes


  • Feb 27th, 2017

8 Bytes..

  Was this answer useful?  Yes

Rajeshwar Reddy

  • Jun 3rd, 2017


It will take only 2bytes, because comp occupy only two bytes for 1 to 4 bytes.
9(3)v9(7) is 3.7bytes because V is a decimal point

  Was this answer useful?  Yes

Ganesh Dudhigani

  • Jun 13th, 2017

It will take 8bytes for it.
9(1) to 9(4) = 2bytes
9(5) to 9(9) = 4bytes
9(10) to 9(18) = 8bytes

  Was this answer useful?  Yes

raghul kumar

  • Aug 17th, 2017

As far as I learned comp cannot hold decimal values, if you give this statement compiler will show an error

  Was this answer useful?  Yes


  • Aug 19th, 2017

COMP holds binary values and COMP has predetermined length to data types
9(1)-9(4) = 2 bytes
9(5)-9(9) = 4 bytes
9(10)-9(18) = 8 bytes..
9(3)v9(7) occupies 8 bytes but the question itself wrong COMP variable doesnt have a PIC clause bcz it already contains a predetermined data size.

  Was this answer useful?  Yes


  • Mar 7th, 2018

Comp is integer values. Comp3 for decimal values.
decimal declaration with comp will give compiler error.

  Was this answer useful?  Yes


  • Aug 17th, 2018

Hello - Since there is a V , this computational usage must be COMP-3. Now in COMP-3 where it is signed or unsigned the sign is stored in the last 4 bits. 9(3)V9(7) COMP-3 will thus occupy 6bytes. Thank you.

  Was this answer useful?  Yes


  • Dec 5th, 2018

COMP will store the values in binary format and
from 9(1) -9(4) it will occupy 2 bytes
from 9(5) -9(8) it will occupy 4 bytes
from 9(9) -9(18) it will occupy 8 bytes

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions