[gnumeric] fn-eng: better fix for long double issue.



commit ccb61c29b6021501000b96f5cde89e8ba2184761
Author: Morten Welinder <terra gnome org>
Date:   Sun Feb 6 13:52:53 2022 -0500

    fn-eng: better fix for long double issue.

 plugins/fn-eng/functions.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/plugins/fn-eng/functions.c b/plugins/fn-eng/functions.c
index 398e7f47f..44658f00d 100644
--- a/plugins/fn-eng/functions.c
+++ b/plugins/fn-eng/functions.c
@@ -136,21 +136,21 @@ val_to_base (GnmFuncEvalInfo *ei,
 
        case VALUE_FLOAT: {
                gnm_float val = gnm_fake_trunc (value_get_as_float (vstring ? vstring : value));
-               char buf[GNM_MANT_DIG + 10];
+               char *buf;
                char *err;
+               gboolean fail;
 
                value_release (vstring);
 
                if (val < min_value || val > max_value)
                        return value_new_error_NUM (ei->pos);
 
-               // For long-double we need a better replacement for this
-               g_ascii_formatd (buf, sizeof (buf) - 1,
-                                "%.0f",
-                                (double)val);
-
+               buf = g_strdup_printf ("%.0" GNM_FORMAT_f, val);
                v = g_ascii_strtoll (buf, &err, src_base);
-               if (*err != 0)
+               fail = (*err != 0);
+               g_free (buf);
+
+               if (fail)
                        return value_new_error_NUM (ei->pos);
                break;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]