[fitsbits] 64-bit integers
William Pence
William.D.Pence at nasa.gov
Wed May 4 12:12:28 EDT 2005
It appears that most software environments (e.g., C/C++, Fortran, Java, IDL,
Tcl/tk, ...) now support 64-bit integers. Can anyone cite a case where
this is not true? Note that C compilers can define this type differently,
so it might be declared as 'long long' (on many 32-bit systems), 'long' (on
many newer 64-bit computers), or '__int64' (on early versions of Microsoft
Visual C++).
In the case of CFITSIO, the new 3.0 beta release now requires that the C
compiler have a 64-bit integer data type. This version has only been out
for about a month, but so far no one has reported any problems compiling it.
Here are a couple other secondary issues about 64-bit integer support that
I'm aware of:
- some languages only support signed 64-bit integers, and do not natively
support unsigned 64-bit integers (e.g., Fortran and Java, I think). In
these systems integer values greater than 2**63 would appear as negative
values. Software applications that must support the full range of unsigned
64-bit integers could probably be written to test for any negative values,
and then reinterpret the value as the correct unsigned value.
- many libraries written in C (including CFITSIO) rely on the 'cfortran.h'
macros, written by Burkhard Burow, to provide the machine-independent
Fortran interface to the library routines. cfortran.h does not support
64-bit integers, so, for example, Fortran programmers currently cannot use
CFITSIO to directly read or write 64-bit integers in FITS file. It is still
possible to read/write the 64-bit integer FITS values cast as double
precision floating point variables in the Fortran program, but this is not a
generally acceptable alternative. The eventual solution to this problem
will be to add support for the 64-bit integer data type to cfortran.h,
however these macros are VERY complicated, so it will require someone with a
lot of expertise in C and Fortran to do this.
Bill Pence
Mark Calabretta wrote:
>>Given the past controversies about adding 64-bit integer support to FITS, it
>>is somewhat remarkable that there has been so little discussion of this now.
>
> I support the proposal, though with one reservation: how will cfitsio
> (or your favourite FITS reader) load a BITPIX=64 image onto a 32-bit
> computer? Are we assuming the availability of "long long int" in C
> (as is gcc), INTEGER*8 (or whatever it is) in FORTRAN, and similarly
> in other languages? Will coercing these values to double precision be
> considered acceptable if 64-bit integers are not available?
--
____________________________________________________________________
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