Re: NAN as _FillValue/missing_value

Chris Webster a écrit :

I went to convert my _FillValue to NAN; I found that upon reading data and doing comparisons a false is always returned:

  if (datum[i] == vp->attr->missingValue)  // is always false if nan's

At first I thought I was back in the world of round off hell until I was pointed to:

http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm

specifically these lines:

  "A NAN will never return true on a <= comparison," and

"One other complication is that comparisons involving NANs are always supposed to return false, "



I would like to suggest that mention of this be made on the netCDF Best Practices page where you point people to use NAN as the _FillValue.

...then I'd like to whine that I have to retro-fit all my code and double the number of checks for every data point to determine if it's _Fill/missing (...using isnan(3)). :)

--Chris

In our code we always compare default values (_FillValue or
missing_value) with a function in
case of theese are NaN.

This function looks like:
Boolean IsDefault(double X, Y)
{
 if (isnan(X))
   return isnan(Y)
 else
   return X == Y;
}

For files we create we never use a NaN value but a fully representable
float (i.e. a number which does
not have representation problem and rounding risk) like 2.0E200


--
   Philippe Poilbarbe    CLS Océanographie Spatiale

mailto:Philippe.Poilbarbe@xxxxxxxxxxxx
phoneto:+33(5)61394727
        
Parc technologique du canal
8-10, Rue Hermes
31526 Ramonville St-Agne


  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: