Index: /branches/eam_branches/ipp-20121219/Ohana/src/libfits/table/F_get_column.c
===================================================================
--- /branches/eam_branches/ipp-20121219/Ohana/src/libfits/table/F_get_column.c	(revision 35091)
+++ /branches/eam_branches/ipp-20121219/Ohana/src/libfits/table/F_get_column.c	(revision 35092)
@@ -96,9 +96,18 @@
   }
   if (!strcmp (type, "int64_t")) {
-    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
-# ifdef BYTE_SWAP
-      SWAP_DBLE;
-# endif
-      *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
+    if ((Bzero == 0.0) && (Bscale == 1.0)) {
+      for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
+# ifdef BYTE_SWAP
+	SWAP_DBLE;
+# endif
+	*(int64_t *)Pout = *(int64_t *)Pin;
+      }
+    } else {
+      for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
+# ifdef BYTE_SWAP
+	SWAP_DBLE;
+# endif
+	*(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
+      }
     }
   }
@@ -243,9 +252,19 @@
   }
   if (!strcmp (type, "int64_t")) {
-    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
-# ifdef BYTE_SWAP
-      SWAP_DBLE;
-# endif
-      *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
+    // XXX 64 bit int operations with Bzero & Bscale are inaccurate even with doubles
+    if ((Bzero == 0.0) && (Bscale == 1.0)) {
+      for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
+# ifdef BYTE_SWAP
+	SWAP_DBLE;
+# endif
+	*(int64_t *)Pout = *(int64_t *)Pin;
+      }
+    } else {
+      for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
+# ifdef BYTE_SWAP
+	SWAP_DBLE;
+# endif
+	*(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
+      }
     }
   }
Index: /branches/eam_branches/ipp-20121219/Ohana/src/libfits/table/F_set_column.c
===================================================================
--- /branches/eam_branches/ipp-20121219/Ohana/src/libfits/table/F_set_column.c	(revision 35091)
+++ /branches/eam_branches/ipp-20121219/Ohana/src/libfits/table/F_set_column.c	(revision 35092)
@@ -102,4 +102,22 @@
     }
   }
+  if (!strcmp (type, "int64_t")) {
+    // XXX 64 bit int operations with Bzero & Bscale are inaccurate even with doubles
+    if ((Bzero == 0.0) && (Bscale == 1.0)) {
+      for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) {
+	*(int64_t *)Pout = *(int64_t *)Pin;
+# ifdef BYTE_SWAP
+	SWAP_DBLE;
+# endif
+      }
+    } else {
+      for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) {
+	*(int64_t *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+	SWAP_DBLE;
+# endif
+      }
+    }
+  }
   if (!strcmp (type, "float")) {
     for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) {
@@ -228,4 +246,13 @@
     }
   }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "char")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      SWAP_DBLE;
+# endif
+    }
+  }
   if (!strcmp (outtype, "float") && !strcmp (intype, "char")) {
     int NbytesIn = 1;
@@ -272,4 +299,13 @@
     }
   }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "short")) {
+    int NbytesIn = 2;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(short *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      SWAP_DBLE;
+# endif
+    }
+  }
   if (!strcmp (outtype, "float") && !strcmp (intype, "short")) {
     int NbytesIn = 2;
@@ -316,4 +352,13 @@
     }
   }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "int")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(int *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      SWAP_DBLE;
+# endif
+    }
+  }
   if (!strcmp (outtype, "float") && !strcmp (intype, "int")) {
     int NbytesIn = 4;
@@ -329,4 +374,57 @@
     for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
       *(double *)Pout = (*(int *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      SWAP_DBLE;
+# endif
+    }
+  }
+
+  /** input == int64_t **/
+  if (!strcmp (outtype, "char") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(char *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "short") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(short *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      SWAP_BYTE;
+# endif
+    }  
+  }
+  if (!strcmp (outtype, "int") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      SWAP_WORD;
+# endif
+    }
+  }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      SWAP_DBLE;
+# endif
+    }
+  }
+  if (!strcmp (outtype, "float") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(float *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      SWAP_WORD;
+# endif
+    }
+  }
+  if (!strcmp (outtype, "double") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(double *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
 # ifdef BYTE_SWAP
       SWAP_DBLE;
@@ -360,4 +458,13 @@
     }
   }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "float")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(float *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      SWAP_DBLE;
+# endif
+    }
+  }
   if (!strcmp (outtype, "float") && !strcmp (intype, "float")) {
     int NbytesIn = 4;
@@ -401,4 +508,13 @@
 # ifdef BYTE_SWAP
       SWAP_WORD;
+# endif
+    }
+  }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "double")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(double *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      SWAP_DBLE;
 # endif
     }
