Page 1 of 1

COMP-1 and COMP-2 in COBOL.

Posted: Sat Oct 16, 2021 8:06 pm
by bscott
Hi,

I have been asked an interview question recently which goes like this:

What do you mean by COMP-1 and COMP-2 in COBOL?

I answered it like this :

COMP-1 refers to a short or single-precision floating-point format, and it occupies storage of 4 bytes. COMP-2 refers to Long or double-precision floating-point format, and it occupies storage of 2 bytes.

The next question from interviewer left me speechless, He said, this is bookish definition tell me some practical use of it. Which I could not tell, could someone please help me with this.

Re: COMP-1 and COMP-2 in COBOL.

Posted: Sat Oct 23, 2021 5:07 pm
by raghvan obrai
You have answered it so well. What else would someone look for an answer than this?

Even if you get selected don't work for them.

Re: COMP-1 and COMP-2 in COBOL.

Posted: Wed Oct 27, 2021 12:51 am
by Robert Sample
If you are dealing with scientific numbers which exceed the limit of exact decimals (18 digits normally, 31 digits if ARITH(EXTEND) is specified at compile time), then COMP-1 or COMP-2 would be required. Which to use would depend upon how many digits of precision were needed -- COMP-1 will not exceed 7 digits. It is rare to use either in COBOL but not unheard of.

Re: COMP-1 and COMP-2 in COBOL.

Posted: Wed Oct 27, 2021 9:09 am
by bscott
That means for regular use of COBOL, where most of the applications are written for Banking we don't use COMP-1 and COMP2 that usually, right?