COBOL decimal number limit.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Manju Mainframe
Registered Member
Posts: 24
Joined: Mon Aug 12, 2013 10:50 am

COBOL decimal number limit.

Post 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?
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: COBOL decimal number limit.

Post 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.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: COBOL decimal number limit.

Post 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).
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: COBOL decimal number limit.

Post 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.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”