This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Formatted Read Accuracy
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: Emil Block <blime at his dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 09 Oct 2002 21:44:25 +0200
- Subject: Re: Formatted Read Accuracy
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <3DA43F4E.CC8DF6AC@his.com>
Emil Block wrote:
When reading a number from an input file with a formatted read statement the
value is not represented correctly when using the G77 compiler. For example,
read (line,3) xllt
3 format(f9.4)
input xllt is 67.9936 and it becomes 67.9935989
Anyone know how to correct this?
You can't. 67.9935989 is the approximation that's choosen by the input
algorithm of 67.9936 because the latter can't be represented exactly in
single precision floating point format.
You simply have to live with this, because it's a feature of dealing
with floating point values.
Hope this helps,
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)