Floating point NaN values as Keywords

Arnold Rots arots at xebec.gsfc.nasa.gov
Tue Aug 12 14:00:01 EDT 1997


> 
> Bob Garwood <bgarwood at nrao.edu> writes:
> 
> > Pense's cfitsio library will write out "NaN" when given a keyword
> > value that is a NaN, at least under Linux and Solaris.
> 
> Is this formatted as a string in this case, or do the NaN "digits"
> appear as a real valued keyword?  The latter would be illegal.
> 
> Any viable solution will likely have to agree with the original FITS
> FORTRAN-derived format rules.  The golden "once FITS, always FITS" rule
> doesn't actually forbid expanding the definition of a real number by
> adding newly allowed values - but this seems like a mighty big change.
> Note that restricting (as opposed to "deprecating") previously allowed
> values would be forbidden, on the other hand.)

However, if one wants to be able to distinguish a NaN unambiguously
from the string value "'NaN'", then one would have to extend the
definition of a float to include the "digits" NaN (case significant?).
I understand that this is a major change that may have to get the
IAU FWG blessing, but if one does this, one might as well do it right.

> 
> > What does anyone else feel about NaN values and keywords?
> 
> Is NaN the only IEEE feature that needs to be considered?  The mapping
> between a binary IEEE data representation and an ASCII FITS keyword is
> unlikely to ever be perfect.

Indefs and Infins?

> 
> I see no easy way to support NaN for any keywords that are required to
> be type real by the standard (e.g., BSCALE/BZERO).  FITS "user" keywords
> are not explicitly typed in general, on the other hand, and an otherwise
> real keyword could be retyped as a string to express a NaN.
> 
> This presents a bit of a complication for software to handle, but in
> practice shouldn't be too big a deal.  Many packages will likely parse
> a real/string value correctly already - assuming they can handle NaN's,
> that is.  Only applications that need to read that particular keyword
> will care in any event.

To complicate matters further, there is the precedent of arrays
of numbers encoded as comma-separated lists in a string ...
Retyping a float keyword as a string could work, but requires
two things: the string should not represent a number (such as '42')
and only NaNs could be thus encoded.

> 
> Rob Seaman
> -- 
> seaman at noao.edu, http://iraf.noao.edu/~seaman
> NOAO, 950 N Cherry Ave, Tucson AZ 85719, 520-318-8248
> PGP: 98 8D 8B 49 74 9A 41 88  3A 43 87 54 51 BF 30 4B
> 
> 

  - Arnold Rots




More information about the fitsbits mailing list