<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Problem with calculation of a sum in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810496#M42428</link>
    <description>Be careful. The epsilon you list eps=0.000000059604644775390625000000000000000000000000 (the single precision) is only valid when comparing with a number who's magnitude is approximately 1.0. If the numbers you deal with are on the order of 1.0E+6 then eps=0.059604644775390625000000000000000000000000. Same issue with more precision when delaing with double precision. Any eps has to be crafted for the numbers you are dealing with.&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
    <pubDate>Wed, 08 Jun 2011 17:26:50 GMT</pubDate>
    <dc:creator>jimdempseyatthecove</dc:creator>
    <dc:date>2011-06-08T17:26:50Z</dc:date>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810490#M42422</link>
      <description>Hello&lt;BR /&gt;&lt;BR /&gt;i use Visual Studio 2008 (Version 9.0.21022.8) and Intel Fortran Compiler 11.0.3454.2008.&lt;BR /&gt;&lt;BR /&gt;I wrote a simple program that should calculate this equation:&lt;BR /&gt;&lt;BR /&gt;x1+x2-x3-x4*3 &lt;BR /&gt;with&lt;BR /&gt;x1 =32.04243&lt;BR /&gt;x2 =18.01534&lt;BR /&gt;x3 =44.00995 &lt;BR /&gt;x4 = 2.01594 &lt;BR /&gt; &lt;BR /&gt;with these parameter the sum had to be 0.0.&lt;BR /&gt;&lt;BR /&gt;This is my program:  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; program test&lt;BR /&gt;&lt;BR /&gt; !molar mass of species[kg/kmol]&lt;BR /&gt; real*8 :: x1,x2,x3,x4 &lt;BR /&gt; real*8 :: Massdotsum &lt;BR /&gt; &lt;BR /&gt; x1 =32.04243D0&lt;BR /&gt; x2 =18.01534D0&lt;BR /&gt; x3 =44.00995D0&lt;BR /&gt; x4 = 2.01594D0&lt;BR /&gt; &lt;BR /&gt; Massdotsum=0.0D0&lt;BR /&gt; print*,'0', Massdotsum&lt;BR /&gt; Massdotsum=x1+x2-x3-x4*3.0D0 &lt;BR /&gt; print*, x1,x2,x3,x4,x4*3.0D0&lt;BR /&gt; print*,'1', Massdotsum,x1+x2-x3-x4*3.0D0&lt;BR /&gt; pause&lt;BR /&gt; &lt;BR /&gt; end program&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;but the result of the program is always:&lt;BR /&gt;1.7763568E-15&lt;BR /&gt;&lt;BR /&gt;has anybody an idea what mistake i make, &lt;BR /&gt;or is this a bug?&lt;BR /&gt;&lt;BR /&gt;Thanks for your help!&lt;BR /&gt;Bastian&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Jun 2011 16:57:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810490#M42422</guid>
      <dc:creator>bastiangerman</dc:creator>
      <dc:date>2011-06-07T16:57:09Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810491#M42423</link>
      <description>If your intention is to calculate&lt;BR /&gt;(x1+(x2-x4*3)) -x3&lt;BR /&gt;you must write it with parentheses. &lt;BR /&gt;If the compiler required the option /assume:protect_parens in order to get the correct result with parentheses added, you might consider that a bug. Without the parentheses, the compiler can't be expected to analyze your code to figure out the most accurate order of operations.&lt;BR /&gt;Yes, when you have alternating signs and proceed in order of increasing magnitude, you can minimize roundoff error without invoking extra precision. If you want extra precision, you should be able to get it with the 32-bit compiler with /arch:IA32 -Qpc80</description>
      <pubDate>Tue, 07 Jun 2011 17:25:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810491#M42423</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2011-06-07T17:25:51Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810492#M42424</link>
      <description>&lt;BR /&gt;makes one wonder: when is a 0 a 0? when there are 14 0's in front of it?&lt;BR /&gt;1.7763568E-15??&lt;BR /&gt;(of course this is when comparing it to the numbers you were working with to arrive at that number)&lt;BR /&gt;i'm reminded of the 1977 Forsythe, Malcolm 'computer methods for mathematical computers' which had the simple 'machine epsilon program:&lt;BR /&gt;"the accuracy of floating point arithmetic can be characterized by machine epsilon, the smallest floating point number  such that : 1 +  &amp;gt; 1"&lt;BR /&gt;&lt;BR /&gt;the program went as follows:&lt;BR /&gt;&lt;BR /&gt;Eps = 1.&lt;BR /&gt;10 Eps = 0.5*Eps&lt;BR /&gt;epsp1 = Eps + 1.&lt;BR /&gt;if (Epsp1 .gt. 1.) go to 10&lt;BR /&gt;&lt;BR /&gt;(gotta love them goto's!)&lt;BR /&gt;&lt;BR /&gt;Then use that epsilon to decide when 0 is 0 (or close enough for government work (ok, that's oild too...back in the day when govt funded research)&lt;BR /&gt;&lt;BR /&gt;brian&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Jun 2011 22:54:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810492#M42424</guid>
      <dc:creator>bmchenry</dc:creator>
      <dc:date>2011-06-07T22:54:36Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810493#M42425</link>
      <description>When you do calculations with none integers, it is very unlikely that your result is what you expect.&lt;BR /&gt;&lt;BR /&gt;Our math teacher back in school show us the trick 1 / 3 * 3 = 0.9999999999.&lt;BR /&gt;&lt;BR /&gt;Somewhere in this forum was a old, but very good article series which dealt with how floating point operations are being done by the CPU but I cant find it any more.&lt;BR /&gt;&lt;BR /&gt;So, you have to accept the fact that your CPU result differs from the real result. It becomes worse when you do something like&lt;BR /&gt;&lt;BR /&gt;if a &amp;lt;= b&lt;BR /&gt;&lt;BR /&gt;Just say, a is your result 1.7763568E15 and b is 0, so the if would return false as a result. For that you need some epsilon to do the trick (but without any gotos...)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Markus&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Jun 2011 08:21:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810493#M42425</guid>
      <dc:creator>onkelhotte</dc:creator>
      <dc:date>2011-06-08T08:21:14Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810494#M42426</link>
      <description>I seem to remember that there iseven a theoretical difficulty to determine if a particular &lt;BR /&gt;expression is exactly zero (quite apart from floating-point approximations).&lt;BR /&gt;&lt;BR /&gt;The above algorithm to determine epsilon fails in two ways:&lt;BR /&gt;- It determines epsilon/2&lt;BR /&gt;- On machines that use extended precision but store the data as single or double precision,&lt;BR /&gt; you get a value that is way too small&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Arjen</description>
      <pubDate>Wed, 08 Jun 2011 09:06:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810494#M42426</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2011-06-08T09:06:19Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810495#M42427</link>
      <description>this am work up early to send out a file and on startup my computer gave me the ole...chkdsk needed issue...&lt;BR /&gt;so while waiting for the 'main' computer to come to life on another computer for the fun of it i did a single (REAL) and double precision Real(8) version of the EPS program from Forsythe and guess what came out of it...&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;single precision: 24 steps: eps=0.000000059604644775390625000000000000000000000000&lt;BR /&gt;double precision: 53 steps: eps=0.000000000000000111022302462515654042363166809082 &lt;/P&gt;&lt;P&gt;that double precision number of zeros is mighty close the the E-15 number you found.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2011 13:39:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810495#M42427</guid>
      <dc:creator>bmchenry</dc:creator>
      <dc:date>2011-06-08T13:39:47Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810496#M42428</link>
      <description>Be careful. The epsilon you list eps=0.000000059604644775390625000000000000000000000000 (the single precision) is only valid when comparing with a number who's magnitude is approximately 1.0. If the numbers you deal with are on the order of 1.0E+6 then eps=0.059604644775390625000000000000000000000000. Same issue with more precision when delaing with double precision. Any eps has to be crafted for the numbers you are dealing with.&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Jun 2011 17:26:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810496#M42428</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2011-06-08T17:26:50Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810497#M42429</link>
      <description>You can use the nearest() function: it returns the greatest number smaller than a given one&lt;BR /&gt;or the lowest number larger than a given one:&lt;BR /&gt;&lt;BR /&gt;next_greater = nearest( x,1.0)&lt;BR /&gt;next_lower = nearest( x, -1.0 )&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Arjen</description>
      <pubDate>Thu, 09 Jun 2011 10:21:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810497#M42429</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2011-06-09T10:21:02Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810498#M42430</link>
      <description>RRSPACING may also be handy.</description>
      <pubDate>Thu, 09 Jun 2011 15:23:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810498#M42430</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-06-09T15:23:57Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810499#M42431</link>
      <description>Steve, Im looking for an article series I mentioned before.&lt;BR /&gt;&lt;BR /&gt;Its back from the Compaq days IIRC. There are several parts dealing with how floating point operations work, what NAN means and so on.&lt;BR /&gt;&lt;BR /&gt;Do you know the link? I dont know if it is on some Intel server or an external link.</description>
      <pubDate>Tue, 14 Jun 2011 10:08:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810499#M42431</guid>
      <dc:creator>onkelhotte</dc:creator>
      <dc:date>2011-06-14T10:08:55Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810500#M42432</link>
      <description>How about this link:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://download.oracle.com/docs/cd/E19957-01/806-3568/ncg_goldberg.html"&gt; What Every Computer Scientist Should Know About Floating-Point Arithmetic&lt;/A&gt; by David Goldberg.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Jun 2011 10:24:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810500#M42432</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-06-14T10:24:47Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810501#M42433</link>
      <description>You could also take a look at the Visual Fortran Newsletter (archive) under Useful Links and see Steve's articles on "The perils of real numbers" parts 1 and 2 &lt;BR /&gt;&lt;EDIT&gt; (Originally written by Dave Eklund of Compaq I believe, Steve will correct me if I'm wrong)&lt;BR /&gt;&lt;BR /&gt;Les&lt;/EDIT&gt;</description>
      <pubDate>Tue, 14 Jun 2011 11:09:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810501#M42433</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2011-06-14T11:09:29Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810502#M42434</link>
      <description>Les is correct - Dave's articles can be found &lt;A href="http://software.intel.com/en-us/forums/showthread.php?t=41911&amp;amp;o=d&amp;amp;s=lr"&gt;here&lt;/A&gt;. Dave came along with me to Intel and is still with us here.</description>
      <pubDate>Tue, 14 Jun 2011 16:10:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810502#M42434</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-06-14T16:10:28Z</dc:date>
    </item>
    <item>
      <title>Problem with calculation of a sum</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810503#M42435</link>
      <description>The Perils of real numbers - That was the article I was looking for!&lt;BR /&gt;&lt;BR /&gt;Thanks a lot!</description>
      <pubDate>Wed, 15 Jun 2011 11:03:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-calculation-of-a-sum/m-p/810503#M42435</guid>
      <dc:creator>onkelhotte</dc:creator>
      <dc:date>2011-06-15T11:03:51Z</dc:date>
    </item>
  </channel>
</rss>

