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

Getting more than 18 digit decimal values


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

New User


Joined: 13 Feb 2008
Posts: 3
Location: pune

PostPosted: Wed Feb 13, 2008 5:22 pm
Reply with quote

hi frnds,

in my calaculator program which i am coding in cobol i have to calaulate

22/7 and user has the liberty to calcaulate the as many decimal points he wants as:

22/7 and if he spcified 3 so it should be 22/7=3.142 after decimal 3 digits if he is passing 10,20,30 so those no of digits should come after decimal point

danish
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Feb 13, 2008 5:50 pm
Reply with quote

Do you know how to do 'long division'?
For the dynamic-ness you want, you will need to to he calculation like you would do long division, guess & subtract over and over again....
Back to top
View user's profile Send private message
danish
Currently Banned

New User


Joined: 13 Feb 2008
Posts: 3
Location: pune

PostPosted: Wed Feb 13, 2008 6:29 pm
Reply with quote

Please can some one put one example for that one??????????
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Feb 13, 2008 6:52 pm
Reply with quote

danish,

what is your input? how do you receive the input?

apparently, you have input for a mulitplicand and a multiplier and number of decimal positions?

the product definition is based on decimal positions and significant digits.

you mentioned 10,20,30......... unless you change compiler options (for this homework program i would not bother) you only have 18 positions.

so if you have 10 decimal positions, you only have room for 8 significant digits. plus a sign.

so you are going to have to limit the number of decimal positions.

and depending upon the number of decimal positions, you could use an evaluate to decide what the product definition will be.

prod-def-1 pic s9(17)v9.
prod-def-2 pic s9(16)v99. .......
Back to top
View user's profile Send private message
danish
Currently Banned

New User


Joined: 13 Feb 2008
Posts: 3
Location: pune

PostPosted: Mon Feb 18, 2008 5:04 pm
Reply with quote

so can't we take more than 18 decimal places
Back to top
View user's profile Send private message
priya

Moderator


Joined: 24 Jul 2003
Posts: 568
Location: Bangalore

PostPosted: Mon Feb 18, 2008 5:30 pm
Reply with quote

We can. But you cant understand, even if we explain to you now!

Search the forums, then come back here, after you learned about compiler Options, IBM & Enterprice cobol enhancements & external floating point literals.
Back to top
View user's profile Send private message
star_dhruv2000

New User


Joined: 03 Nov 2006
Posts: 87
Location: Plymouth, MN USA

PostPosted: Mon Feb 18, 2008 8:23 pm
Reply with quote

Hi,

Normally Compliers resist to use maximum of 18 digit number.

But if you use ARITH(EXTEND) compiler option, maximum number of digit positions that you can specify in the PICTURE clause for packed-decimal, external-decimal, and numeric-edited data items is raised from 18 to 31.

Cheers! icon_smile.gif
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Mon Feb 18, 2008 9:10 pm
Reply with quote

Why bother with the calculation of 22/7 each time. It is an approximation at best, like every other PI value that you terminate. Grab the first 31 digits and put them into a constant. Then truncate that number to the size you need and use NUMVAL(?) (is that the right funtion) to convert it to a decimal value with.

WS-PI PIC X(32) VALUE '3.1415926535897932384626433832'
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Mon Feb 18, 2008 9:12 pm
Reply with quote

Anything beyond the 30 positions after the decimal and you will have to implement it yourself in some fashion.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 19, 2008 7:15 pm
Reply with quote

Do a little bit of web reading on long decimal numbers ( with arbitrary number of digits )
starting from
http://www2.hursley.ibm.com/decimal/
very rewarding from a theoretical point of view
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
Search our Forums:

Back to Top