IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 6, 2013, 3:20:55 PM (13 years ago)
Author:
eugene
Message:

add support for int64 columns in tables (was only partial in the past)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libfits/table/F_get_column.c

    r33648 r35101  
    9696  }
    9797  if (!strcmp (type, "int64_t")) {
    98     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    99 # ifdef BYTE_SWAP
    100       SWAP_DBLE;
    101 # endif
    102       *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
     98    if ((Bzero == 0.0) && (Bscale == 1.0)) {
     99      for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
     100# ifdef BYTE_SWAP
     101        SWAP_DBLE;
     102# endif
     103        *(int64_t *)Pout = *(int64_t *)Pin;
     104      }
     105    } else {
     106      for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
     107# ifdef BYTE_SWAP
     108        SWAP_DBLE;
     109# endif
     110        *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
     111      }
    103112    }
    104113  }
     
    243252  }
    244253  if (!strcmp (type, "int64_t")) {
    245     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    246 # ifdef BYTE_SWAP
    247       SWAP_DBLE;
    248 # endif
    249       *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
     254    // XXX 64 bit int operations with Bzero & Bscale are inaccurate even with doubles
     255    if ((Bzero == 0.0) && (Bscale == 1.0)) {
     256      for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
     257# ifdef BYTE_SWAP
     258        SWAP_DBLE;
     259# endif
     260        *(int64_t *)Pout = *(int64_t *)Pin;
     261      }
     262    } else {
     263      for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
     264# ifdef BYTE_SWAP
     265        SWAP_DBLE;
     266# endif
     267        *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
     268      }
    250269    }
    251270  }
Note: See TracChangeset for help on using the changeset viewer.