Index: /branches/eam_branches/ohana.20160226/src/libohana/include/ohana.h
===================================================================
--- /branches/eam_branches/ohana.20160226/src/libohana/include/ohana.h	(revision 39422)
+++ /branches/eam_branches/ohana.20160226/src/libohana/include/ohana.h	(revision 39423)
@@ -486,6 +486,6 @@
 int ohana_bisection_double (double *values, int Nvalues, double threshold);
 
-int sprintf_float (char *output, float value);
-int sprintf_double (char *output, double value);
+unsigned int sprintf_float (char *output, float value);
+unsigned int sprintf_double (char *output, double value);
 
 /* in gaussdev.c */
Index: /branches/eam_branches/ohana.20160226/src/libohana/src/sprintf_floats.c
===================================================================
--- /branches/eam_branches/ohana.20160226/src/libohana/src/sprintf_floats.c	(revision 39422)
+++ /branches/eam_branches/ohana.20160226/src/libohana/src/sprintf_floats.c	(revision 39423)
@@ -8,5 +8,5 @@
 
 // returns the number of bytes written EXCLUDING the ending NULL char
-int sprintf_float (char *output, float value) {
+unsigned int sprintf_float (char *output, float value) {
 
   // I want a fast way to print a float in %e format.  Simplifying assumptions: print a
@@ -117,5 +117,5 @@
 
 // returns the number of bytes written EXCLUDING the ending NULL char
-int sprintf_double (char *output, double value) {
+unsigned int sprintf_double (char *output, double value) {
 
   // I want a fast way to print a float in %e format.  Simplifying assumptions: print a
Index: /branches/eam_branches/ohana.20160226/src/libohana/test/sprintf_floats.c
===================================================================
--- /branches/eam_branches/ohana.20160226/src/libohana/test/sprintf_floats.c	(revision 39422)
+++ /branches/eam_branches/ohana.20160226/src/libohana/test/sprintf_floats.c	(revision 39423)
@@ -7,28 +7,82 @@
 
 void test_float (float value) {
-  char output[128], string[128];
+  char output[128], string[128], altout[128];
 
-  int Noutput = sprintf_float(output, value);
+  unsigned int Noutput = sprintf_float(output, value);
   ok (Noutput == strlen(output), "right length");
   sprintf (string, "%+14.7e", value);
-  ok (!strcmp (output, string), "right format");
 
-  if (strcmp (output, string)) {
-    fprintf (stderr, "output: %s, string: %s\n", output, string);
+  // due to rounding error (where?), the last digit may differ between sprintf and sprintf_float
+  if (!strcmp (output, string)) {
+    pass ("right format: %s, string: %s", output, string);
+    return;
   }
+
+  strcpy (altout, output);
+  int Co = output[9] - '0';
+  int Ci = string[9] - '0';
+  int valid = (Co - 1 == Ci); // e.g., Co = 8, Ci = 9
+  valid = valid || (Co + 1 == Ci); // e.g., Co = 8, Ci = 7
+  valid = valid || ((Co == 0) && Ci == 9);  // e.g., Co = 0, Ci = 9
+  valid = valid || ((Ci == 0) && Co == 9);  // e.g., Co = 9, Ci = 0
+  if (!valid) {
+    fail ("wrong format: %s, string: %s", output, string);
+    return;
+  }
+  altout[9] = string[9];
+  if ((Co == 0) && (Ci == 9)) {
+    altout[8] = string[8];
+  }
+  if ((Co == 9) && (Ci == 0)) {
+    altout[8] = string[8];
+  }
+  if (!strcmp (altout, string)) {
+    pass ("fixed format: %s, string: %s", output, string);
+  } else {
+    fail ("wrong format: %s, string: %s", output, string);
+  }
+
   return;
 }
 
 void test_double (double value) {
-  char output[128], string[128];
+  char output[128], string[128], altout[128];
 
-  int Noutput = sprintf_double(output, value);
+  unsigned int Noutput = sprintf_double(output, value);
   ok (Noutput == strlen(output), "right length");
   sprintf (string, "%+21.14e", value);
-  ok (!strcmp (output, string), "right format");
 
-  if (strcmp (output, string)) {
-    fprintf (stderr, "output: %s, string: %s\n", output, string);
+  // due to rounding error (where?), the last digit may differ between sprintf and sprintf_float
+  if (!strcmp (output, string)) {
+    pass ("right format: %s, string: %s", output, string);
+    return;
   }
+
+  strcpy (altout, output);
+  int Co = output[16] - '0';
+  int Ci = string[16] - '0';
+  int valid = (Co - 1 == Ci); // e.g., Co = 8, Ci = 9
+  valid = valid || (Co + 1 == Ci); // e.g., Co = 8, Ci = 7
+  valid = valid || ((Co == 0) && Ci == 9);  // e.g., Co = 0, Ci = 9
+  valid = valid || ((Ci == 0) && Co == 9);  // e.g., Co = 9, Ci = 0
+  if (!valid) {
+    fail ("wrong format: %s, string: %s", output, string);
+    return;
+  }
+  altout[16] = string[16];
+  if ((Co == 0) && (Ci == 9)) {
+    altout[15] = string[15];
+    fprintf (stderr, "last two digits .. ");
+  }
+  if ((Co == 9) && (Ci == 0)) {
+    altout[15] = string[15];
+    fprintf (stderr, "last two digits .. ");
+  }
+  if (!strcmp (altout, string)) {
+    pass ("fixed format: %s, string: %s", output, string);
+  } else {
+    fail ("wrong format: %s, string: %s", output, string);
+  }
+
   return;
 }
@@ -43,5 +97,5 @@
   /*** sprint_float ***/
   if (DO_FLOATS) {
-    int Noutput;
+    unsigned int Noutput;
     char output[128];
 
@@ -85,5 +139,5 @@
   /*** sprint_double ***/
   if (DO_DOUBLES) {
-    int Noutput;
+    unsigned int Noutput;
     char output[128];
 
