diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2014-03-19 14:09:08 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2014-03-19 14:09:08 -0700 |
commit | 37ca9077224a3c0e1c2051a47c58148d826812e8 (patch) | |
tree | af3f66c0fc097fc7d69e315734443821703d6c2b /src | |
parent | 6a72e405532b56406306cda56b4e2ef0807e2760 (diff) | |
download | emacs-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')
-rw-r--r-- | src/ChangeLog | 7 | ||||
-rw-r--r-- | src/floatfns.c | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 94859f1f8fd..06e4c3291b5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2014-03-19 Paul Eggert <eggert@cs.ucla.edu> + + Fix porting inconsistency about rounding to even. + * 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. + 2014-03-19 Eli Zaretskii <eliz@gnu.org> * w32fns.c (reset_modifiers): Zero out keystate[] before using it. 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 |