exporting small floats: problem with 0
Nirgal Vourgère <[email protected]> Mon, 2 Aug 2010 13:57:51 +0100
| Newsgroups | gmane.comp.db.mdb-tools.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello Attached is a modified version for patch 130-export-smallfloat Basically, it's ok to use "%e" instead of "%f" but we must NOT call trim_trailing_zeros after that. Or 0.00000000000000e+00 becomes 0.00000000000000e+ that is invalid. http://nirgal.com/mdbtools (squeeze version not updated yet) ------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm _______________________________________________ mdbtools-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mdbtools-dev
130-export-smallfloat
(text/x-diff, 1.1 KB)
Description: mdb-export fails exporting small (1e-7) floats, due to a %f used instead of a %e. Author: Vincent Fourmond <[email protected]> Bug-Debian: http://bugs.debian.org/220403 Last-Update: 2010-08-02 Index: mdbtools-0.6pre1/src/libmdb/data.c =================================================================== --- mdbtools-0.6pre1.orig/src/libmdb/data.c +++ mdbtools-0.6pre1/src/libmdb/data.c @@ -704,6 +704,7 @@ return text; } +#if 0 static int trim_trailing_zeros(char * buff) { char *p; @@ -724,6 +725,7 @@ return 0; } +#endif /* Date/Time is stored as a double, where the whole part is the days from 12/30/1899 and the fractional @@ -837,15 +839,13 @@ break; case MDB_FLOAT: tf = mdb_get_single(buf, start); - text = g_strdup_printf("%.*f", + text = g_strdup_printf("%.*e", FLT_DIG - floor_log10(tf,1) - 1, tf); - trim_trailing_zeros(text); break; case MDB_DOUBLE: td = mdb_get_double(buf, start); - text = g_strdup_printf("%.*f", + text = g_strdup_printf("%.*e", DBL_DIG - floor_log10(td,0) - 1, td); - trim_trailing_zeros(text); break; case MDB_TEXT: if (size<0) {