View previous topic :: View next topic |
Author |
Message |
javedsk12 Beginner
Joined: 14 Dec 2007 Posts: 66 Topics: 36 Location: pune
|
Posted: Wed Feb 13, 2008 1:28 am Post subject: getting 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 _________________ javed
-----------------------
The Word Impossible it self says i am possible(im possible) |
|
Back to top |
|
|
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Wed Feb 13, 2008 9:38 am Post subject: |
|
|
Not a task for a beginner. |
|
Back to top |
|
|
Mervyn Moderator
Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
Posted: Wed Feb 13, 2008 9:39 am Post subject: |
|
|
What's the question, anyway? _________________ The day you stop learning the dinosaur becomes extinct |
|
Back to top |
|
|
cobcurious Beginner
Joined: 04 Oct 2003 Posts: 68 Topics: 25
|
Posted: Sun Feb 17, 2008 11:46 am Post subject: |
|
|
Hi Javed,
Please note that there is an upper limit on the number of digits you can use in COBOL. I think it is 18 digits for a numeric number.
For customising the value of 22/7 ("pi"..I guess), you may have to use either variables of differing lengths. Also equal number of separate "result" variables (in which are going to put down the result of your calculations),depending on the number of digits selected after the decimal point for 22/7, to give you the precision in the result you are expecting.
Thanks
Tushar |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Mon Feb 18, 2008 5:40 am Post subject: |
|
|
I would say you only need one result variable in Packed Decimal format (COMP 3?? - my cobol ain't great) and a zoned decimal version which you can then etract the required length of answer from (after rounding) and a char field to isert the answer into (so that trailing zeros do not exist). Something along those lines anyway. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
|
|
|