[goffice] math: fix go_fake_{ceil,floor}
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] math: fix go_fake_{ceil,floor}
- Date: Tue, 5 Oct 2021 01:59:05 +0000 (UTC)
commit 72bb460861e5254bbca6f2ca83b8a19978df5802
Author: Morten Welinder <terra gnome org>
Date: Mon Oct 4 21:58:35 2021 -0400
math: fix go_fake_{ceil,floor}
And document.
NEWS | 6 ++++++
goffice/math/go-math.c | 22 ++++++++++++++++------
2 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/NEWS b/NEWS
index a5ee0f8a..ddcda622 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,12 @@ Jean:
* Do not clip markers in scatter plots. [#584]
* Draw background and outline for data labels. [#592]
+John Denker:
+ * Fix go_fake_{ceil,floor} confusion. [#56]
+
+Morten:
+ * Introspection updates.
+
--------------------------------------------------------------------------
goffice 0.10.50:
diff --git a/goffice/math/go-math.c b/goffice/math/go-math.c
index 6b0c8a23..b24ee8ec 100644
--- a/goffice/math/go-math.c
+++ b/goffice/math/go-math.c
@@ -240,6 +240,13 @@ go_d2d (double x)
return *px;
}
+/*
+ * go_fake_floor: a variant of floor with a 1ulp grace interval
+ * @x: value to floor
+ *
+ * This works like floor, i.e., rounds to integer in the direction of negative
+ * infinity, except that a value of 1ulp less than an integer will round up.
+ */
double
go_fake_floor (double x)
{
@@ -248,11 +255,16 @@ go_fake_floor (double x)
if (x == floor (x))
return x;
- return (x >= 0)
- ? floor (go_add_epsilon (x))
- : floor (go_sub_epsilon (x));
+ return floor (go_add_epsilon (x));
}
+/*
+ * go_fake_ceil: a variant of ceil with a 1ulp grace interval
+ * @x: value to ceil
+ *
+ * This works like ceil, i.e., rounds to integer in the direction of positive
+ * infinity, except that a value of 1ulp more than an integer will round down.
+ */
double
go_fake_ceil (double x)
{
@@ -261,9 +273,7 @@ go_fake_ceil (double x)
if (x == floor (x))
return x;
- return (x >= 0)
- ? ceil (go_sub_epsilon (x))
- : ceil (go_add_epsilon (x));
+ return ceil (go_sub_epsilon (x));
}
double
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]