Floating point NaN values as Keywords

William Pence pence at tetra.gsfc.nasa.gov
Tue Aug 19 15:15:52 EDT 1997


Bob Garwood wrote:

>    Pence's cfitsio library will write out "NaN" when given a
> keyword value that is a NaN, at least under Linux and Solaris.

This behavior of CFITSIO is not intentional, and is just an accidental
result of a 'non-standard' feature in these C compilers.  I believe
these keywords are illegal according to the FITS standard, so CFITSIO
should return an error if one attempts to write a NaN value to a
keyword.  I'll try to trap these cases in the next release of CFITSIO.

As to the question of how to represent an undefined keyword value
(which is what a NaN represents) I would support the form illustrated
in Garwood's follow-up message:

> Someone here just point out to me that the FITS definition allows
> for the following construct as valid FITS:
> 
> K       =                      / 
> 
> i.e. no value given for the keyword.  Apparently in the FORTRAN-77
> list-directed read this would be interpretted as leaving the
> value of K unchanged. 

This usage has apparently always been legal in FITS (since it follows
the rules for list-directed Fortran-77 reads) but has not been widely
known.  (It is mentioned in the draft of the next version of the FITS
Standard, however).

The latest versions of CFITSIO and FITSIO support this usage.

-Bill Pence
 HEASARC/GSFC




More information about the fitsbits mailing list