]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug with ‘mod’ and float+bignum
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 Aug 2018 06:27:47 +0000 (23:27 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 Aug 2018 06:29:16 +0000 (23:29 -0700)
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
test/src/floatfns-tests.el

index ea2eb1016b1acb8f0de7fc02c76f4bdf70e2c9a9..713d42694fffc6fbfc755d46bc7e7bd451e7cabe 100644 (file)
@@ -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);
 
index 7714c05d60af452ec21d831c482589065539a312..43a2e2782904c4722487e256fc0e8288124b68eb 100644 (file)
@@ -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)