From de04a23ab78c1dbdf6dff57a462d55b77b527cfe Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Fri, 26 Apr 2002 21:01:54 +0000 Subject: Use DBL_DIG to compute how much buffer space to use here. 2002-04-26 Christopher James Lahey * gal/util/e-util.h (E_ASCII_DTOSTR_BUF_SIZE): Use DBL_DIG to compute how much buffer space to use here. * gal/util/e-xml-utils.c (e_xml_set_double_prop_by_name): Use DBL_DIG here to decide how many digits to print. svn path=/trunk/; revision=16604 --- e-util/e-xml-utils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'e-util/e-xml-utils.c') diff --git a/e-util/e-xml-utils.c b/e-util/e-xml-utils.c index fa4f96c1a2..98c089074b 100644 --- a/e-util/e-xml-utils.c +++ b/e-util/e-xml-utils.c @@ -343,15 +343,19 @@ void e_xml_set_double_prop_by_name(xmlNode *parent, const xmlChar *prop_name, gdouble value) { char buffer[E_ASCII_DTOSTR_BUF_SIZE]; + char *format; g_return_if_fail (parent != NULL); g_return_if_fail (prop_name != NULL); if (fabs (value) < 1e9 && fabs (value) > 1e-5) { - e_ascii_dtostr (buffer, sizeof (buffer), "%.17f", value); + format = g_strdup_printf ("%%.%df", DBL_DIG); } else { - e_ascii_dtostr (buffer, sizeof (buffer), "%.17g", value); + format = g_strdup_printf ("%%.%dg", DBL_DIG); } + e_ascii_dtostr (buffer, sizeof (buffer), format, value); + g_free (format); + xmlSetProp (parent, prop_name, buffer); } -- cgit v1.2.3