Re: Question about precision
From: Keith Refson - real email address in signature (nobody_at_nowhere.uk)
Date: 08/25/04
- Next message: Gordon Sande: "Re: Current Usses for Fortran ??"
- Previous message: Richard Maine: "Re: Current Usses for Fortran ??"
- In reply to: Paul Van Delst: "Question about precision"
- Next in thread: Toon Moene: "Re: Question about precision"
- Reply: Toon Moene: "Re: Question about precision"
- Reply: Paul Van Delst: "Re: Question about precision"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 25 Aug 2004 16:46:45 +0100
Paul Van Delst <paul.vandelst@noaa.gov> writes:
> I have code where I need to interpolate several instrument response
> functions to the same frequency grid and begin and end
> frequencies. The data I read in from file is at a set spacing,
> 0.1cm^-1, but after computing that value from the begin and end
> frequency and the number of points, the value is always something like
> 0.1000000000000002cm^-1. This has caused problems since the extra
> 0.0000000000000002 makes a test that I use to ensure the interpolation
> is alway within the actual data (extrapolation is a no-no here),
> fail.
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.
Keith Refson
-- Dr Keith Refson, Building R3 Rutherford Appleton Laboratory Chilton Didcot kr AT Oxfordshire OX11 0QX isise D@T rl D.T ac D?T uk
- Next message: Gordon Sande: "Re: Current Usses for Fortran ??"
- Previous message: Richard Maine: "Re: Current Usses for Fortran ??"
- In reply to: Paul Van Delst: "Question about precision"
- Next in thread: Toon Moene: "Re: Question about precision"
- Reply: Toon Moene: "Re: Question about precision"
- Reply: Paul Van Delst: "Re: Question about precision"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|