aboutsummaryrefslogtreecommitdiffstats
path: root/src/floatfns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/floatfns.c')
-rw-r--r--src/floatfns.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/floatfns.c b/src/floatfns.c
index f3d0936f888..75106a661b7 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -1,7 +1,6 @@
1/* Primitive operations on floating point for GNU Emacs Lisp interpreter. 1/* Primitive operations on floating point for GNU Emacs Lisp interpreter.
2 2
3Copyright (C) 1988, 1993-1994, 1999, 2001-2013 Free Software Foundation, 3Copyright (C) 1988, 1993-1994, 1999, 2001-2014 Free Software Foundation, Inc.
4Inc.
5 4
6Author: Wolfgang Rupprecht 5Author: Wolfgang Rupprecht
7(according to ack.texi) 6(according to ack.texi)
@@ -46,12 +45,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
46 45
47#include <math.h> 46#include <math.h>
48 47
49#ifndef isfinite 48/* 'isfinite' and 'isnan' cause build failures on Solaris 10 with the
50# define isfinite(x) ((x) - (x) == 0) 49 bundled GCC in c99 mode. Work around the bugs with simple
51#endif 50 implementations that are good enough. */
52#ifndef isnan 51#undef isfinite
53# define isnan(x) ((x) != (x)) 52#define isfinite(x) ((x) - (x) == 0)
54#endif 53#undef isnan
54#define isnan(x) ((x) != (x))
55 55
56/* Check that X is a floating point number. */ 56/* Check that X is a floating point number. */
57 57
@@ -141,7 +141,7 @@ DEFUN ("tan", Ftan, Stan, 1, 1, 0,
141} 141}
142 142
143DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0, 143DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0,
144 doc: /* Return non nil iff argument X is a NaN. */) 144 doc: /* Return non nil if argument X is a NaN. */)
145 (Lisp_Object x) 145 (Lisp_Object x)
146{ 146{
147 CHECK_FLOAT (x); 147 CHECK_FLOAT (x);
@@ -427,7 +427,9 @@ round2 (EMACS_INT i1, EMACS_INT i2)
427static double 427static double
428emacs_rint (double d) 428emacs_rint (double d)
429{ 429{
430 return floor (d + 0.5); 430 double d1 = d + 0.5;
431 double r = floor (d1);
432 return r - (r == d1 && fmod (r, 2) != 0);
431} 433}
432#endif 434#endif
433 435