unsigned images

Russell E. Owen owen at astro.washington.edu
Wed Feb 26 14:09:48 EST 1997


In article <5ep2l1$nko at electra.saaf.se>, pausch at electra.saaf.se (Paul
Schlyter) wrote:

>In article <5ekod7$17m at netline-fddi.jpl.nasa.gov>,
>Bill Owen <wmo at wansor.jpl.nasa.gov> wrote:
> 
> (regarding converting unsigned data into signed, for FITS data output)...
>>
>>       IF (VALUE(I) .GE. 0) THEN
>>          VALUE(I) = VALUE(I) - 32768
>>       ELSE
>>          VALUE(I) = VALUE(I) + 32768
>>       END IF
> 
>This is non-portable, since it assumes integers are stored as
>2-complement binary numbers, and ANSI FORTRAN has no such requirements
>on integers.  Your code will fail on platforms using 1-complement
>or sign-magnitude integer representations - not to mention BCD
>representation..... yes, there are FORTRAN implementations using
>BCD for integers.

Unfortunately true. Is it even possible to have an algorithm that works for
all of the commonly found integer representations? I could not think of
one. This is one good argument for supporting unsigned FITS images -- it
involves less mucking around with machine-specific and compiler-specific
internals.

Meanwhile, I don't see much choice except to code for a specific integer
representation.

-- Russell




More information about the fitsbits mailing list