Make logb handle bignums
* src/floatfns.c (Flogb): Handle bignums. * test/src/floatfns-tests.el (bignum-logb): New test.
This commit is contained in:
parent
3dea8f8f53
commit
cca0e79ea8
2 changed files with 8 additions and 1 deletions
|
@ -328,7 +328,7 @@ This is the same as the exponent of a float. */)
|
|||
(Lisp_Object arg)
|
||||
{
|
||||
EMACS_INT value;
|
||||
CHECK_FIXNUM_OR_FLOAT (arg);
|
||||
CHECK_NUMBER (arg);
|
||||
|
||||
if (FLOATP (arg))
|
||||
{
|
||||
|
@ -345,8 +345,11 @@ This is the same as the exponent of a float. */)
|
|||
else
|
||||
value = MOST_POSITIVE_FIXNUM;
|
||||
}
|
||||
else if (BIGNUMP (arg))
|
||||
value = mpz_sizeinbase (XBIGNUM (arg)->value, 2) - 1;
|
||||
else
|
||||
{
|
||||
eassert (FIXNUMP (arg));
|
||||
EMACS_INT i = eabs (XINT (arg));
|
||||
value = (i == 0
|
||||
? MOST_NEGATIVE_FIXNUM
|
||||
|
|
|
@ -42,4 +42,8 @@
|
|||
(should (= most-positive-fixnum
|
||||
(- (abs most-negative-fixnum) 1))))
|
||||
|
||||
(ert-deftest bignum-logb ()
|
||||
(should (= (+ (logb most-positive-fixnum) 1)
|
||||
(logb (+ most-positive-fixnum 1)))))
|
||||
|
||||
(provide 'floatfns-tests)
|
||||
|
|
Loading…
Add table
Reference in a new issue