[gnumeric] Handle denormals better.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Handle denormals better.
- Date: Wed, 17 May 2017 01:12:47 +0000 (UTC)
commit bd07ea76616ac604c07abf7bb4f608db7b282d57
Author: Morten Welinder <terra gnome org>
Date: Tue May 16 21:11:50 2017 -0400
Handle denormals better.
Accept them instead of turning things into strings that we then cannot
deal with.
ChangeLog | 6 ++++++
src/gutils.c | 14 ++++++++++++--
src/value.c | 3 +++
3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6d82e92..1cbd108 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-16 Morten Welinder <terra gnome org>
+
+ * src/gutils.c (gnm_utf8_strto): Handle denormals better.
+
+ * src/value.c (value_new_from_string): Handle denormals betters.
+
2017-04-05 Morten Welinder <terra gnome org>
* src/sf-trig.c (gnm_reduce_pi): Rename from reduce_pi_half.
diff --git a/src/gutils.c b/src/gutils.c
index cfdc059..fd1337a 100644
--- a/src/gutils.c
+++ b/src/gutils.c
@@ -206,8 +206,10 @@ gnm_utf8_strto (const char *s, char **end)
gnm_float res;
int save_errno;
- if (all_ascii (s))
- return gnm_strto (s, end);
+ if (all_ascii (s)) {
+ res = gnm_strto (s, end);
+ goto handle_denormal;
+ }
ascii = g_string_sized_new (100);
@@ -271,6 +273,14 @@ gnm_utf8_strto (const char *s, char **end)
g_string_free (ascii, TRUE);
errno = save_errno;
+
+handle_denormal:
+ save_errno = errno;
+ if (res != 0 && gnm_abs (res) < GNM_MIN)
+ errno = 0;
+ else
+ errno = save_errno;
+
return res;
}
diff --git a/src/value.c b/src/value.c
index d1b0daf..30e1993 100644
--- a/src/value.c
+++ b/src/value.c
@@ -510,6 +510,9 @@ value_new_from_string (GnmValueType t, char const *str, GOFormat *sf,
gnm_float d;
d = gnm_strto (str, &end);
+ if (d != 0 && d > -GNM_MIN && d < GNM_MIN)
+ errno = 0;
+
if (str != end && *end == '\0' && errno != ERANGE)
res = value_new_float (d);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]