[goffice] Math: further fixes to go_add_epsilon fallback code.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Math: further fixes to go_add_epsilon fallback code.
- Date: Thu, 17 Feb 2022 22:54:50 +0000 (UTC)
commit 099667409dfa2ce506e0aeedfedf65fc739cde3b
Author: Morten Welinder <terra gnome org>
Date: Thu Feb 17 17:53:39 2022 -0500
Math: further fixes to go_add_epsilon fallback code.
Largely untested, but should handle switch-over from one binade
to the next.
ChangeLog | 4 ++++
goffice/math/go-math.c | 12 ++++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a673c5f6..0a46ba3f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2022-02-17 Morten Welinder <terra gnome org>
+
+ * goffice/math/go-math.c (go_add_epsilon): Fix fallback code.
+
2022-01-21 Morten Welinder <terra gnome org>
* goffice/gtk/go-action-combo-stack.c: Reimplement based on
diff --git a/goffice/math/go-math.c b/goffice/math/go-math.c
index b50961f4..ccd8e5af 100644
--- a/goffice/math/go-math.c
+++ b/goffice/math/go-math.c
@@ -213,7 +213,8 @@ go_add_epsilon (double x)
else {
int e;
double mant = frexp (fabs (x), &e);
- return ldexp (mant + DBL_EPSILON, e);
+ // mant is in range [0.5; 1)
+ return ldexp (mant + DBL_EPSILON / 2, e);
}
#endif
}
@@ -238,7 +239,8 @@ go_sub_epsilon (double x)
else {
int e;
double mant = frexp (fabs (x), &e);
- return ldexp (mant - DBL_EPSILON, e);
+ // mant is in range [0.5; 1)
+ return ldexp (mant - (mant == 0.5 ? DBL_EPSILON / 4 : DBL_EPSILON / 2), e);
}
#endif
}
@@ -764,7 +766,8 @@ go_add_epsilonl (long double x)
else {
int e;
long double mant = frexpl (fabsl (x), &e);
- return ldexpl (mant + LDBL_EPSILON, e);
+ // mant is in range [0.5; 1)
+ return ldexpl (mant + LDBL_EPSILON / 2, e);
}
#endif
}
@@ -789,7 +792,8 @@ go_sub_epsilonl (long double x)
else {
int e;
long double mant = frexpl (fabsl (x), &e);
- return ldexpl (mant - LDBL_EPSILON, e);
+ // mant is in range [0.5; 1)
+ return ldexpl (mant - (mant == 0.5L ? LDBL_EPSILON / 4 : LDBL_EPSILON / 2), e);
}
#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]