Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
danish
Currently Banned

New User

Joined: 13 Feb 2008
Posts: 3
Location: pune

 Posted: Wed Feb 13, 2008 5:22 pm    Post subject: Getting more than 18 digit decimal values 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

CICS Guy

Senior Member

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

 Posted: Wed Feb 13, 2008 5:50 pm    Post subject: 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....
danish
Currently Banned

New User

Joined: 13 Feb 2008
Posts: 3
Location: pune

 Posted: Wed Feb 13, 2008 6:29 pm    Post subject: Please can some one put one example for that one??????????
dbzTHEdinosauer

Global Moderator

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

 Posted: Wed Feb 13, 2008 6:52 pm    Post subject: 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. .......
danish
Currently Banned

New User

Joined: 13 Feb 2008
Posts: 3
Location: pune

 Posted: Mon Feb 18, 2008 5:04 pm    Post subject: so can't we take more than 18 decimal places
priya

Moderator

Joined: 24 Jul 2003
Posts: 568
Location: Bangalore

 Posted: Mon Feb 18, 2008 5:30 pm    Post subject: Reply to: getting decimal values 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.
star_dhruv2000

New User

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

 Posted: Mon Feb 18, 2008 8:23 pm    Post subject: 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!
stodolas

Active Member

Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

 Posted: Mon Feb 18, 2008 9:10 pm    Post subject: 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'
stodolas

Active Member

Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

 Posted: Mon Feb 18, 2008 9:12 pm    Post subject: Anything beyond the 30 positions after the decimal and you will have to implement it yourself in some fashion.
enrico-sorichetti

Global Moderator

Joined: 14 Mar 2007
Posts: 10457
Location: italy

 Posted: Tue Feb 19, 2008 7:15 pm    Post subject: Reply to: Getting more than 18 digit decimal values 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
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics LOW VALUES as a KEY juares castro DB2 10 Sat Apr 07, 2018 1:06 am Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am How to group and sum the decimal value sakrat DFSORT/ICETOOL 2 Tue Mar 06, 2018 9:13 pm attchmvs from rexx subroutine that re... harisukumaran CLIST & REXX 1 Fri Jan 19, 2018 5:29 am Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us