Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Getting more than 18 digit decimal values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Getting more than 18 digit decimal values
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: 2150
Location: At my coffee table

PostPosted: Wed Feb 13, 2008 5:50 pm    Post subject:
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    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Wed Feb 13, 2008 6:52 pm    Post subject:
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    Post subject:
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    Post subject: Reply to: getting decimal values
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    Post subject:
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    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10326
Location: italy

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

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 4 Tue Jul 25, 2017 12:12 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us