Use DBL_DIG to compute how much buffer space to use here.
2002-04-26 Christopher James Lahey <clahey@ximian.com> * 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
This commit is contained in:

committed by
Chris Lahey

parent
68cb7c9340
commit
de04a23ab7
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user