IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Declaring numeric variable to handle more than 31 digits


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ranjith741

New User


Joined: 04 Jun 2013
Posts: 9
Location: India

PostPosted: Wed Apr 30, 2014 12:02 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Wed Apr 30, 2014 12:41 pm
Reply with quote

Why is there a need to have more than 31? what is the source for your program?
Back to top
View user's profile Send private message
Ranjith741

New User


Joined: 04 Jun 2013
Posts: 9
Location: India

PostPosted: Wed Apr 30, 2014 12:50 pm
Reply with quote

Actually this program is designed to be used as a currency coverter alongwith some business logic. Hence each digit after decimal point matters icon_confused.gif
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


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

PostPosted: Wed Apr 30, 2014 1:08 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Wed Apr 30, 2014 1:31 pm
Reply with quote

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.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Wed Apr 30, 2014 1:49 pm
Reply with quote

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
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Wed Apr 30, 2014 2:06 pm
Reply with quote

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...
Back to top
View user's profile Send private message
Ranjith741

New User


Joined: 04 Jun 2013
Posts: 9
Location: India

PostPosted: Wed Apr 30, 2014 2:52 pm
Reply with quote

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
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Wed Apr 30, 2014 3:15 pm
Reply with quote

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).
Back to top
View user's profile Send private message
Ranjith741

New User


Joined: 04 Jun 2013
Posts: 9
Location: India

PostPosted: Wed Apr 30, 2014 3:31 pm
Reply with quote

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. icon_exclaim.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Apr 30, 2014 4:13 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Apr 30, 2014 4:21 pm
Reply with quote

I didn't think Turkish Lira was being used anymore? icon_lol.gif
Back to top
View user's profile Send private message
seagull

New User


Joined: 28 May 2007
Posts: 24
Location: Dublin

PostPosted: Wed May 28, 2014 4:04 pm
Reply with quote

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.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Overwriting SSN Digits in Easytrieve ... CA Products 0
No new posts REXX/CMS How to place command console... CLIST & REXX 4
No new posts CA7 count with DATE variable CA Products 0
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top