Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org [SOLVED] Intrinsic function PRECISION in GFortran - how it works?
 Linux - Newbie This Linux forum is for members that are new to Linux. Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

 11-16-2014, 06:07 PM #1 AlexBB Member   Registered: Mar 2014 Posts: 444 Rep: Intrinsic function PRECISION in GFortran - how it works? Hi there. My environment: Win7==>Oracle VB==>Ubuntu==>GFortran. I need to check if my computations which involve long recurrences lose precision. There is an intrinsic function PRECISION (X) in Fortran. My question is: Let's say I defined a function f(x). Inside of this function there is a variable res which is a part of a do loop and the loop takes let's say 50 recurrences thus changing the variable res 50 times. Every time it is a bunch of additions and multiplications. Can I apply the PRECISION (res) function after that to determine if I've lost any significant digits? Thanks, A.
 11-17-2014, 11:09 AM #2 suicidaleggroll LQ Guru Contributing Member   Registered: Nov 2010 Location: Colorado Distribution: OpenSUSE, CentOS Posts: 5,561 Rep: No. That function would tell you what the precision of the current variable is (somewhere around 7 significant digits if single precision, 15 if double), but it wouldn't be able to tell you if some mathematical operation you've performed in the past was truncated due to lack of precision. The best option is to run through the math yourself, either that or re-run the same process with a double or a quad to see if there is any significant difference. 2 members found this post helpful.
 11-17-2014, 12:17 PM #3 AlexBB Member   Registered: Mar 2014 Posts: 444 Original Poster Rep: suicidaleggroll, thanks again. I sort of did some research last night and came to the same conclusion. I do have a question, however, while I have you here :-) Will this declaration REAL (KIND=16) :: x guarantee the quadruple precision for the variable x? Thanks A. Last edited by AlexBB; 11-17-2014 at 12:45 PM.
 11-17-2014, 02:37 PM #4 suicidaleggroll LQ Guru Contributing Member   Registered: Nov 2010 Location: Colorado Distribution: OpenSUSE, CentOS Posts: 5,561 Rep: I usually just use REAL*16
 11-17-2014, 03:26 PM #5 John VV LQ Muse   Registered: Aug 2005 Location: A2 area Mi. Posts: 17,245 Rep: with FORTRAN Keep your HP calculator NEXT TO THE KEYBOARD run the math !!! as you test the code
 11-17-2014, 05:12 PM #6 AlexBB Member   Registered: Mar 2014 Posts: 444 Original Poster Rep: John W., My calculations are very long, unfortunately. Still, is it OK to use KIND=16 ?

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Dstruct0 Programming 0 10-05-2011 08:46 PM buddyamit Programming 5 07-08-2011 01:07 AM McCoder Programming 4 07-09-2010 10:28 AM Tahir Butt Programming 3 06-15-2009 09:52 PM alred Programming 5 05-12-2006 02:07 AM

LinuxQuestions.org

All times are GMT -5. The time now is 08:17 AM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -