# Declaring numeric variable to handle more than 31 digits

Author Message
Ranjith741

New User

Joined: 04 Jun 2013
Posts: 9
Location: India

 Posted: Wed Apr 30, 2014 12:02 pm Hi, I want to declare a Working Storage variable in the program 10 XYZ-AMT PIC S9(18)V9(18). I have tried the compiler option CBL ARITH(EXTEND) but it is allowing a maximum of 31 digits. Can anyone suggest any ideas to handle 36 digits numeric variable. Thanks in advance.
Rohit Umarjikar

Global Moderator

Joined: 21 Sep 2010
Posts: 2727
Location: NYC,USA

 Posted: Wed Apr 30, 2014 12:41 pm Why is there a need to have more than 31? what is the source for your program?
Ranjith741

New User

Joined: 04 Jun 2013
Posts: 9
Location: India

 Posted: Wed Apr 30, 2014 12:50 pm Actually this program is designed to be used as a currency coverter alongwith some business logic. Hence each digit after decimal point matters
Nic Clouston

Global Moderator

Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

 Posted: Wed Apr 30, 2014 1:08 pm Go see the person who specified the program logic. ask them how many decimals should be used. Generally no more than 5 or 6 should be required.
Rohit Umarjikar

Global Moderator

Joined: 21 Sep 2010
Posts: 2727
Location: NYC,USA

Posted: Wed Apr 30, 2014 1:31 pm

 Quote: Hence each digit after decimal point matters

How does 0.000000000000000001 value impacts or improves your currency converter?? Please show us any sample calculations.
enrico-sorichetti

Superior Member

Joined: 14 Mar 2007
Posts: 10796
Location: italy

Posted: Wed Apr 30, 2014 1:49 pm

 Quote: Generally no more than 5 or 6 should be required.

the majority of the requirements is satisfied by using 2 decimal digits more than the decimal digits displayed

E.G.: 4 decimals displayed 6 decimals used for computations
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7310
Location: Inside the Matrix

 Posted: Wed Apr 30, 2014 2:06 pm If you really feel that you need 36 digits it is simple. You define one field of 18 for the integer part, and an second field of 18 for the decimal part. Then you process them separately. Would this be necessary for a currency-conversion? Not in the least, it would be absurd, but if it's The Requirement...
Ranjith741

New User

Joined: 04 Jun 2013
Posts: 9
Location: India

Posted: Wed Apr 30, 2014 2:52 pm

 Quote: How does 0.000000000000000001 value impacts or improves your currency converter?? Please show us any sample calculations.

Thanks for your inputs Rohit. This is purely a Business requirement. As developers, do not have much say over the Business significance of these values.

 Quote: You define one field of 18 for the integer part, and an second field of 18 for the decimal part.

Thanks Bill. I was keeping this as a last option and looking for any way around.

Thanks you guys for providing your inputs.

Regards,
Ranjith Kumar
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7310
Location: Inside the Matrix

 Posted: Wed Apr 30, 2014 3:15 pm I think you should take at least one shot at talking to them about this. What do they need 18 integer digits for? 123,456,789,123,456,789. In any existing traded currency, that is far bigger than could be needed excluding massive hyper-inflation. Unless reporting to an absurd and useless number of decimals, you will never need anywhere near 18 digits. Even using extended-double-precision (or whatever it is called) floating point values, I don't think you can can 36 significant digits. In fact I'm certain you can't. So what is the point of the whole thing? If it makes no sense, you don't just do it without a struggle with them first, because it may mean that you have missed something (or they have).
Ranjith741

New User

Joined: 04 Jun 2013
Posts: 9
Location: India

 Posted: Wed Apr 30, 2014 3:31 pm Sure Bill. I will definitely raise this as a serious concern to right folks. Just wanted to check all the available options before highlighting this as a genuine show stopper.
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8578
Location: Dubuque, Iowa, USA

 Posted: Wed Apr 30, 2014 4:13 pm There is no way in COBOL to handle more than 31 digits as a single variable. If you cannot get the requirement changed to something more reasonable, you will have to use two variables for the data as suggested.
Bill O'Boyle

CICS Moderator

Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

 Posted: Wed Apr 30, 2014 4:21 pm I didn't think Turkish Lira was being used anymore?
seagull

New User

Joined: 28 May 2007
Posts: 24
Location: Dublin

 Posted: Wed May 28, 2014 4:04 pm The only reason I can see for that number of decimals is someone wanting to know how many Zimbabwean dollars you get for £0.000000000000000001 Except that the Zimbabwean dollar is no longer in use.
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics Trying to reference a javascript glob... CLIST & REXX 7 passing stem variable with VPUT/VGET ... CLIST & REXX 6 Numeric check on packed signed and un... COBOL Programming 4 DECIMAL HOST VARIABLE OR PARAMETER 14... DB2 7 How to add 2 digits to COMP-3 file? DFSORT/ICETOOL 11
Search our Forums: