diff options
| author | Paul Eggert | 2014-03-19 14:09:08 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-03-19 14:09:08 -0700 |
| commit | 37ca9077224a3c0e1c2051a47c58148d826812e8 (patch) | |
| tree | af3f66c0fc097fc7d69e315734443821703d6c2b /src/floatfns.c | |
| parent | 6a72e405532b56406306cda56b4e2ef0807e2760 (diff) | |
| download | emacs-37ca9077224a3c0e1c2051a47c58148d826812e8.tar.gz emacs-37ca9077224a3c0e1c2051a47c58148d826812e8.zip | |
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.c | 4 |
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) | |||
| 428 | static double | 428 | static double |
| 429 | emacs_rint (double d) | 429 | emacs_rint (double d) |
| 430 | { | 430 | { |
| 431 | return floor (d + 0.5); | 431 | double d1 = d + 0.5; |
| 432 | double r = floor (d1); | ||
| 433 | return r - (r == d1 && fmod (r, 2) != 0); | ||
| 432 | } | 434 | } |
| 433 | #endif | 435 | #endif |
| 434 | 436 | ||