https://software.intel.com/de-de/forums/topic/378305/feed
deThank you very much.https://software.intel.com/de-de/comment/1728363#comment-1728363
<a id="comment-1728363"></a>
<div class="field field-name-comment-body field-type-text-long field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Thank you very much.</p>
</div></div></div>Sun, 17 Mar 2013 02:15:22 +0000felipe.marchant@gmail.comcomment 1728363 at https://software.intel.comQuote:Felipe Marchant wrote:https://software.intel.com/de-de/comment/1728348#comment-1728348
<a id="comment-1728348"></a>
<div class="field field-name-comment-body field-type-text-long field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p><strong class="quote-header">Quote:</strong><blockquote class="quote-msg quote-nest-1 odd"><div class="quote-author"><em class="placeholder">Felipe Marchant</em> wrote:</div></p>
<p>Thank you for answering. Ok, so I am clear about the differences existing in the codes; but I do not know if you could help me also with respect to the issue of reading a value from a file, that is reads only approximately (eg. 0.3 in the file is read as 0.299999999999999 in double precision). Sorry for inconvenience and thanks.</p>
<p>Regards.</p>
<p></blockquote></p>
<p>This is, effectively, the same problem. 0.3 is another number whose representation in binary is a repeating fraction. The I/O library can only produce the closest binary number to what your file contains. If you print out that result to enough digits, you can see the difference. Ideally, if that number is being read into a double precision variable, the I/O library should produce the same approximate representation as the compiler chooses for 0.3d0, and if that number is being read into a single precision variable, the I/O library should produce the same approximate representation as the compiler chooses for 0.3 or 0.3e0, but in either case, the value stored in the varikable is still only an approximation of the decimal value being presented. Except in very special cases, the expectation that floating point numbers will represent the result of any operation exactly is contrary to the reality of computer arithmetic and likely to lead you into trouble.</p>
</div></div></div>Sat, 16 Mar 2013 19:01:38 +0000hirchert728comment 1728348 at https://software.intel.comThank you for answering. Ok,https://software.intel.com/de-de/comment/1728314#comment-1728314
<a id="comment-1728314"></a>
<div class="field field-name-comment-body field-type-text-long field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Thank you for answering. Ok, so I am clear about the differences existing in the codes; but I do not know if you could help me also with respect to the issue of reading a value from a file, that is reads only approximately (eg. 0.3 in the file is read as 0.299999999999999 in double precision). Sorry for inconvenience and thanks.</p>
<p>Regards.</p>
</div></div></div>Sat, 16 Mar 2013 00:10:10 +0000felipe.marchant@gmail.comcomment 1728314 at https://software.intel.comThere are a number of redhttps://software.intel.com/de-de/comment/1728296#comment-1728296
<a id="comment-1728296"></a>
<div class="field field-name-comment-body field-type-text-long field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>There are a number of red herrings in your questions, but the key point is that computers do their arithmetic and representation of numbers in binary rather than decimal, so while 1.1 may appear to you to be a number that can be represented exactly, to the computer it is a number whose representation is a repeating fraction, analogous to 1 and 1/7 being 1.142857142857... in decimal. For any given number of binary digits, the computer can use the closest number it has to 1.1 using that number of digits, but it willnot be exact.</p>
<p>In the first code sequence, you used 1.1d0, which a double precision constant, about as precise as using 1.142857142857143 for 1 and 1/7. Inthe second sequence, you used 1.1, which is a single precision constant, only about as precise as using 1.142857 for 1 and 1/7. Thus, it should come as no surprise that the first sequence gives better results.</p>
<p>If your variables are declared double precision, 1.1 will be converted to a double precision value, but unfortunately this is like converting 1.142857 to 1.142857000000000. It may be a double precision value, but isn't the double precision value you would want for best double precision results.</p>
</div></div></div>Fri, 15 Mar 2013 21:07:29 +0000hirchert728comment 1728296 at https://software.intel.com