b8a1d025b9e09702debcf84cd656be0cf8032a62
braney
  Thu Feb 20 11:46:12 2020 -0800
work around a problem with %g going into scientific notation too early

diff --git src/lib/common.c src/lib/common.c
index 2dc4671..e6b6f06 100644
--- src/lib/common.c
+++ src/lib/common.c
@@ -3753,15 +3753,28 @@
     dateAdd(&tp,addYears,addMonths,addDays); // tp.tm_year only contains years since 1900
     strftime(newDate,12,format,&tp);
     }
 return cloneString(newDate);  // newDate is never freed!
 }
 
 boolean haplotype(const char *name)
 /* Is this name a haplotype name ?  _hap or _alt in the name */
 {
 if (stringIn("_hap", name) || stringIn("_alt", name))
    return TRUE;
 else
    return FALSE;
 }
 
+char *shorterDouble(double value)
+/* Work around a "bug" in %g output that goes into scientific notation too early. */
+{
+static char gbuffer[4096];
+static char g15buffer[4096];
+
+sprintf(gbuffer, "%g", value);
+sprintf(g15buffer, "%.15g", value);
+
+if (strlen(gbuffer) < strlen(g15buffer))
+    return gbuffer;
+return g15buffer;
+}