[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 06b5bcd: Fix bug with ‘mod’ and float+bignum
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 06b5bcd: Fix bug with ‘mod’ and float+bignum |
Date: |
Sun, 19 Aug 2018 02:29:20 -0400 (EDT) |
branch: master
commit 06b5bcd639bf97fc77dc89dd52f136d4f262e888
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Fix bug with ‘mod’ and float+bignum
Problem reported by Andy Moreton in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00442.html
* src/floatfns.c (fmod_float): Work even if an arg is a bignum.
* test/src/floatfns-tests.el (bignum-mod): New test.
---
src/floatfns.c | 6 ++----
test/src/floatfns-tests.el | 3 +++
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/floatfns.c b/src/floatfns.c
index ea2eb10..713d426 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -514,10 +514,8 @@ With optional DIVISOR, truncate ARG/DIVISOR. */)
Lisp_Object
fmod_float (Lisp_Object x, Lisp_Object y)
{
- double f1, f2;
-
- f1 = FLOATP (x) ? XFLOAT_DATA (x) : XFIXNUM (x);
- f2 = FLOATP (y) ? XFLOAT_DATA (y) : XFIXNUM (y);
+ double f1 = XFLOATINT (x);
+ double f2 = XFLOATINT (y);
f1 = fmod (f1, f2);
diff --git a/test/src/floatfns-tests.el b/test/src/floatfns-tests.el
index 7714c05..43a2e27 100644
--- a/test/src/floatfns-tests.el
+++ b/test/src/floatfns-tests.el
@@ -46,4 +46,7 @@
(should (= (+ (logb most-positive-fixnum) 1)
(logb (+ most-positive-fixnum 1)))))
+(ert-deftest bignum-mod ()
+ (should (= 0 (mod (1+ most-positive-fixnum) 2.0))))
+
(provide 'floatfns-tests)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 06b5bcd: Fix bug with ‘mod’ and float+bignum,
Paul Eggert <=