This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Formatted Read Accuracy


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]