Re: Question about precision

From: Toon Moene (toon_at_moene.indiv.nluug.nl)
Date: 08/25/04


Date: Wed, 25 Aug 2004 22:16:32 +0200

Keith Refson - real email address in signature wrote:

> Might I suggest a different approach. Your problem arises because
> your grid spacing of 0.1 cm^-1 has no exact representation in binary
> floating point. But the numerical value depends on the units
> and can be changed to suit. If your program used internal units of
> 0.1cm^-1 then the grid spacing would be 1.0 which *is* exactly representable.
> In fact you could use integers which would eliminate representation
> and rounding errors entirely.

May I endorse this principle - and indeed it is far more principled than
the example given here:

"Don't count using floating point numbers."

(I wish I had space in my signature for this - it's the most frequent
  problem I have to point out to g77 bug reporters, co-workers and
  other people).

-- 
Toon Moene - e-mail: toon@moene.indiv.nluug.nl - phone: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
A maintainer of GNU Fortran 95: http://gcc.gnu.org/fortran/


Relevant Pages

  • Re: Numeric leak
    ... floating point works fine up to the limit of the number of mantissa ... counting with floating point numbers when the integers are ... Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html ...
    (comp.lang.fortran)
  • Re: C Text/Binary Files
    ... Complain to the maintainer of the above forum that the signature ...
    (comp.lang.c)