Subject: Double Precision FITS keyword values

From: landsman at stars.gsfc.nasa.gov (Wayne Landsman (301)-286-3625)
Date: Mon, 16 Mar 1992 01:31:00 GMT

Section 5.3 of the FITS/NOST manual discusses the allowed fixed formats
for the value of a FITS keyword.   Apparently, double precision values
are not allowed, since the full 64 bit precision cannot be specified
within columns 11-30.   (But 20 characters IS sufficient to specify values
that are more precise than can be expressed by floating point.)

This prompts a couple of related questions:

    (1)   What is the best way to encode a double precision FITS keyword value?

    (2)   If a FITS reader encounters a numeric value with too many digits
to be expressed as floating point, should it convert this value to double
precision?   My FITS reader currently converts a FITS header value to  
double precision if it contains more than 8 numerals.

Thanks for any comments on this.   

Wayne Landsman
landsman at stars.gsfc.nasa.gov
(301)-286-3625

---

From: pence at heawk1.gsfc.nasa.gov ( William Pence)
Date: Mon, 16 Mar 1992 18:15:13 GMT

landsman at stars.gsfc.nasa.gov (Wayne Landsman (301)-286-3625) wrote:

>?within columns 11-30.   (But 20 characters IS sufficient to specify values

The NOST document, section 5.3.1. only states that the fixed format in
column 11-30 is required for the MANDITORY keywords and is just
recommended for other keywords.  Thus, one is free to use all of
columns 11-80 if needed or desired for the value of non-manditory
keywords.   In my FITSIO interface I format a double precision value
greater than 20 characters long by beginning it in column 11 and
extending it for as many columns as necessary to write the required
number of decimal places.

In general, a FITS reader should not assume that an integer, logical,
or single precision floating point value will be right-justified in
columns 11-30.  This is not required by the FITS standard, so the
reader should be prepared to find the keyword value anywhere in columns
11-80.   In the FITSIO code the only assumption I make is that the
value field is the first non-blank token in columns 11-80 of the
keyword record.  I then assume that the comment is contained in any
remaining columns.  (Except if this is a Complex keyword value, in which
case the first token is the real part, the second token is the imaginary
part and the remainder is the comment).

>double precision if it contains more than 8 numerals.

This sounds reasonable, but it rather depends on what you are
reading the FITS file into.  If the keyword value is being read into a
FORTRAN variable, for instance, the variable would have to be
dimensioned as double precision in the first place.