summaryrefslogtreecommitdiff
path: root/src/floatfns.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-03-19 14:09:08 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2014-03-19 14:09:08 -0700
commit37ca9077224a3c0e1c2051a47c58148d826812e8 (patch)
treeaf3f66c0fc097fc7d69e315734443821703d6c2b /src/floatfns.c
parent6a72e405532b56406306cda56b4e2ef0807e2760 (diff)
downloademacs-37ca9077224a3c0e1c2051a47c58148d826812e8.tar.gz
Fix porting inconsistency about rounding to even.
* doc/lispref/numbers.texi (Numeric Conversions, Rounding Operations): Document that 'round' and 'fround' round to even. * src/floatfns.c (emacs_rint) [!HAVE_RINT]: Round to even. This way, the unusual !HAVE_RINT case acts like the usual HAVE_RINT case, and we can fix the documentation accordingly.
Diffstat (limited to 'src/floatfns.c')
-rw-r--r--src/floatfns.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/floatfns.c b/src/floatfns.c
index 4de5f480259..ac0447ce6d6 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -428,7 +428,9 @@ round2 (EMACS_INT i1, EMACS_INT i2)
static double
emacs_rint (double d)
{
- return floor (d + 0.5);
+ double d1 = d + 0.5;
+ double r = floor (d1);
+ return r - (r == d1 && fmod (r, 2) != 0);
}
#endif