* src/floatfns.c (extract_float, Ffloat): Handle bignums.
* src/lisp.h (XFLOATINT): Handle bignums.
* test/src/floatfns-tests.el (bignum-to-float): New test.
double
extract_float (Lisp_Object num)
{
- CHECK_FIXNUM_OR_FLOAT (num);
+ CHECK_NUMBER (num);
return XFLOATINT (num);
}
\f
doc: /* Return the floating point number equal to ARG. */)
(register Lisp_Object arg)
{
- CHECK_FIXNUM_OR_FLOAT (arg);
+ CHECK_NUMBER (arg);
+ if (BIGNUMP (arg))
+ return make_float (mpz_get_d (XBIGNUM (arg)->value));
if (FIXNUMP (arg))
return make_float ((double) XINT (arg));
else /* give 'em the same float back */
INLINE double
XFLOATINT (Lisp_Object n)
{
+ if (BIGNUMP (n))
+ return mpz_get_d (XBIGNUM (n)->value);
return FLOATP (n) ? XFLOAT_DATA (n) : XINT (n);
}
(should-error (ftruncate 0) :type 'wrong-type-argument)
(should-error (fround 0) :type 'wrong-type-argument))
+(ert-deftest bignum-to-float ()
+ (should (eql (float (+ most-positive-fixnum 1))
+ (+ (float most-positive-fixnum) 1))))
+
(provide 'floatfns-tests)