[goffice] Math: use rint in go_rint.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Math: use rint in go_rint.
- Date: Thu, 3 Apr 2014 00:23:30 +0000 (UTC)
commit 6bb793ee336673ff5c0fd1433a7e99d7c46c0089
Author: Morten Welinder <terra gnome org>
Date: Wed Apr 2 20:22:45 2014 -0400
Math: use rint in go_rint.
This avoids stick issues with 2^51, for example.
ChangeLog | 1 +
configure.ac | 2 +-
goffice/math/go-math.c | 4 ++++
3 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7d973c9..87da0e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
* goffice/math/go-math.c (go_fake_round): Fix problem for 2^51 and
like integers.
(go_fake_roundl): Ditto, although for different set of numbers.
+ (go_rint): Just use rint.
* tests/test-format.c: New test program.
diff --git a/configure.ac b/configure.ac
index 708d58f..c9b56c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,7 +565,7 @@ if test $ac_cv_func_log = no; then
LIBS="$LIBS -lm"])
fi
-AC_CHECK_FUNCS(nextafter nextafterl)
+AC_CHECK_FUNCS(nextafter nextafterl rint)
SAVE_CFLAGS=$CFLAGS
SAVE_LIBS=$LIBS
diff --git a/goffice/math/go-math.c b/goffice/math/go-math.c
index 926bc52..5fc01a4 100644
--- a/goffice/math/go-math.c
+++ b/goffice/math/go-math.c
@@ -300,8 +300,12 @@ go_fake_trunc (double x)
double
go_rint (double x)
{
+#ifdef HAVE_RINT
+ return rint (x);
+#else
double y = floor (fabs (x) + 0.5);
return (x < 0) ? -y : y;
+#endif
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]