\f
/* Arithmetic functions */
+#ifndef isnan
+# define isnan(x) ((x) != (x))
+#endif
+
static Lisp_Object
bignumcompare (Lisp_Object num1, Lisp_Object num2,
enum Arith_Comparison comparison)
if (BIGNUMP (num1))
{
if (FLOATP (num2))
- cmp = mpz_cmp_d (XBIGNUM (num1)->value, XFLOAT_DATA (num2));
+ {
+ /* Note that GMP doesn't define comparisons against NaN, so
+ we need to handle them specially. */
+ if (isnan (XFLOAT_DATA (num2)))
+ return Qnil;
+ cmp = mpz_cmp_d (XBIGNUM (num1)->value, XFLOAT_DATA (num2));
+ }
else if (FIXNUMP (num2))
{
if (sizeof (EMACS_INT) > sizeof (long) && XINT (num2) > LONG_MAX)
{
eassume (BIGNUMP (num2));
if (FLOATP (num1))
- cmp = - mpz_cmp_d (XBIGNUM (num2)->value, XFLOAT_DATA (num1));
+ {
+ /* Note that GMP doesn't define comparisons against NaN, so
+ we need to handle them specially. */
+ if (isnan (XFLOAT_DATA (num1)))
+ return Qnil;
+ cmp = - mpz_cmp_d (XBIGNUM (num2)->value, XFLOAT_DATA (num1));
+ }
else
{
eassume (FIXNUMP (num1));
return unbind_to (count, make_number (accum));
}
-#ifndef isnan
-# define isnan(x) ((x) != (x))
-#endif
-
static Lisp_Object
float_arith_driver (double accum, ptrdiff_t argnum, enum arithop code,
ptrdiff_t nargs, Lisp_Object *args)
(should (isnan (min 0.0e+NaN)))
(should (isnan (min 0.0e+NaN 1 2)))
(should (isnan (min 1.0 0.0e+NaN)))
- (should (isnan (min 1.0 0.0e+NaN 1.1))))
+ (should (isnan (min 1.0 0.0e+NaN 1.1)))
+ (should (isnan (min 1.0 0.0e+NaN 1.1 (1+ most-positive-fixnum))))
+ (should (isnan (max 1.0 0.0e+NaN 1.1 (1+ most-positive-fixnum)))))
(defun data-tests-popcnt (byte)
"Calculate the Hamming weight of BYTE."
(should (= (ash most-negative-fixnum 1)
(* most-negative-fixnum 2)))
(should (= (lsh most-negative-fixnum 1)
- (* (abs most-negative-fixnum) 2))))
+ (* most-negative-fixnum 2))))
;;; data-tests.el ends here