Page 1 of 1

COBOL decimal number limit.

Posted: Tue Jun 10, 2014 2:03 pm
by Manju Mainframe
Hi,

What is the maximum decimal position a numeric data item can have in COBOL. When I search for it I got the details about ARTH(EXTEND) but that's about using 31 digits in a numeric number. So does that mean if I want to use a decimal number, it can have 31-digits after decimal with that option active?

Re: COBOL decimal number limit.

Posted: Tue Jun 10, 2014 2:24 pm
by William Collins
For decimal (zoned or packed) 31 digits is the maximum, achieved, as you have pointed out correctly, by using compiler option ARITH(EXTEND). With ARITH(COMPAT) the maximum is 18 digits.

Re: COBOL decimal number limit.

Posted: Tue Jun 10, 2014 11:05 pm
by Robert Sample
The answer partly depends upon what you want to know. As far as fixed-decimal arithmetic, 31 digits is the absolute limit for a single variable in Enterprise COBOL. However, COBOL supports floating point variables that can use larger / smaller values (but the precision won't go over 8 or 16 digits, depending upon which COMP floating point format you use).

Re: COBOL decimal number limit.

Posted: Wed Jun 11, 2014 12:28 pm
by William Collins
ARITH(EXTEND) also increases the number of significant digits for COMP-1/COMP-2 floating-point data. Note that floating-point values are an "approximation" of a true decimal value. Sometimes a little off down a number of decimal places.