From: Tom Tromey Date: Sun, 8 Jul 2018 04:19:21 +0000 (-0600) Subject: Make min and max handle bignums X-Git-Tag: emacs-27.0.90~4598^2~24 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8fb995b9e360270b6a4d7b7732a127a6234eba23;p=emacs.git Make min and max handle bignums * src/data.c (minmax_driver): Handle bignums. * test/src/data-tests.el (data-tests-minmax): New test. --- diff --git a/src/data.c b/src/data.c index 2e366b5313f..7ded8366e32 100644 --- a/src/data.c +++ b/src/data.c @@ -3119,11 +3119,11 @@ minmax_driver (ptrdiff_t nargs, Lisp_Object *args, enum Arith_Comparison comparison) { Lisp_Object accum = args[0]; - CHECK_FIXNUM_OR_FLOAT_COERCE_MARKER (accum); + CHECK_NUMBER_COERCE_MARKER (accum); for (ptrdiff_t argnum = 1; argnum < nargs; argnum++) { Lisp_Object val = args[argnum]; - CHECK_FIXNUM_OR_FLOAT_COERCE_MARKER (val); + CHECK_NUMBER_COERCE_MARKER (val); if (!NILP (arithcompare (val, accum, comparison))) accum = val; else if (FLOATP (val) && isnan (XFLOAT_DATA (val))) diff --git a/test/src/data-tests.el b/test/src/data-tests.el index 561b7bd9ca6..4565cfb3877 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el @@ -590,4 +590,11 @@ comparing the subr with a much slower lisp implementation." (ert-deftest data-tests-logcount () (should (= (logcount (read "#xffffffffffffffffffffffffffffffff")) 128))) +(ert-deftest data-tests-minmax () + (let ((a (- most-negative-fixnum 1)) + (b (+ most-positive-fixnum 1)) + (c 0)) + (should (= (min a b c) a)) + (should (= (max a b c) b)))) + ;;; data-tests.el ends here