Commit 8fb995b9 authored by Tom Tromey's avatar Tom Tromey
Browse files

Make min and max handle bignums

* src/data.c (minmax_driver): Handle bignums.
* test/src/data-tests.el (data-tests-minmax): New test.
parent a770fb44
......@@ -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)))
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment