[fitsbits] 64-bit integer comments

William Pence William.D.Pence at nasa.gov
Thu May 12 17:06:09 EDT 2005


Francois Ochsenbein wrote:
> About the signed/unsigned dilemna for P/Q items in binary tables,
> I tend to prefer the original FITS definitions (published in 
> 1995A&AS..113..159C) which explicitely says "negative offsets are 
> not permitted" -- which defacto limits the value of the P offset 
> to 2**31-1 

Negative offsets could be prohibited in one of 2 ways: a) define the 
descriptor to be a pair of unsigned integers,  or b) define the descriptor 
to be a pair of signed integers and also state that negative values are not 
permitted.   The original paper does not explicitly define the descriptor to 
be signed or unsigned.  Since I haven't seen any strong arguments to 
artificially limit the range to use only 31 bits of the value, my preference 
would be to define it as an unsigned integer and make full use of the range 
from 0 to 2^32 - 1.

It is perhaps worth noting/clarifying that this heap offset value, whether 
we decide to use the full 32 bits or restrict it to only 31 bits, will 
mainly be used in the context of computing a 64-bit integer offset in the 
FITS file to the start of the variable-length array.  This offset is used by 
the low-level disk 'seek' function that is called before reading or writing 
the array.  The formula is given by:

    file_offset = Byte0 + (NAXIS1 * NAXIS2) + heap_offset

where Byte0 is the byte offset in the file to the start of the binary table 
data, and NAXIS1 and NAXIS2 are the width and length of the fixed length 
table that precedes the heap.  In order to support files greater than 2.1 GB 
in size, the other terms in this equation will likely be stored as 64-bit 
integers.  It seems a little ironic to be debating whether to restrict the P 
heap descriptor to 31 bits instead of 32 bits, when its main use will be in 
computing a 64-bit quantity.

Bill
-- 
____________________________________________________________________
Dr. William Pence                          William.D.Pence at nasa.gov
NASA/GSFC Code 662         HEASARC         +1-301-286-4599 (voice)
Greenbelt MD 20771                         +1-301-286-1684 (fax)





More information about the fitsbits mailing list