MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

getting decimal values

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
javedsk12
Beginner


Joined: 14 Dec 2007
Posts: 66
Topics: 36
Location: pune

PostPosted: Wed Feb 13, 2008 1:28 am    Post subject: getting 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
_________________
javed

-----------------------
The Word Impossible it self says i am possible(im possible)
Back to top
View user's profile Send private message
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Wed Feb 13, 2008 9:38 am    Post subject: Reply with quote

Not a task for a beginner.
Back to top
View user's profile Send private message
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Wed Feb 13, 2008 9:39 am    Post subject: Reply with quote

What's the question, anyway?
_________________
The day you stop learning the dinosaur becomes extinct
Back to top
View user's profile Send private message
cobcurious
Beginner


Joined: 04 Oct 2003
Posts: 68
Topics: 25

PostPosted: Sun Feb 17, 2008 11:46 am    Post subject: Reply with quote

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
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Mon Feb 18, 2008 5:40 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group