[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/bignum cca0e79 20/24: Make logb handle bignums
From: |
Tom Tromey |
Subject: |
[Emacs-diffs] feature/bignum cca0e79 20/24: Make logb handle bignums |
Date: |
Fri, 13 Jul 2018 00:25:09 -0400 (EDT) |
branch: feature/bignum
commit cca0e79ea81712786f92a6668c61001e60d24f32
Author: Tom Tromey <address@hidden>
Commit: Tom Tromey <address@hidden>
Make logb handle bignums
* src/floatfns.c (Flogb): Handle bignums.
* test/src/floatfns-tests.el (bignum-logb): New test.
---
src/floatfns.c | 5 ++++-
test/src/floatfns-tests.el | 4 ++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/floatfns.c b/src/floatfns.c
index 6d7fc14..9a5f0a3 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -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
diff --git a/test/src/floatfns-tests.el b/test/src/floatfns-tests.el
index 0911ff4..7714c05 100644
--- a/test/src/floatfns-tests.el
+++ b/test/src/floatfns-tests.el
@@ -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)
- [Emacs-diffs] feature/bignum 872faab 12/24: Allow conversion of bignums to floats, (continued)
- [Emacs-diffs] feature/bignum 872faab 12/24: Allow conversion of bignums to floats, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum 5875fba 08/24: Make arithmetic work with bignums, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum a770fb4 16/24: Make logcount handle bignums, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum 0d86891 14/24: Make 1+ and 1- handle bignums, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum 8fb995b 17/24: Make min and max handle bignums, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum 3dea8f8 19/24: Make % and mod handle bignums, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum d14808c 11/24: Make format handle bignums, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum c7e393b 15/24: Make lognot handle bignums, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum 1e8ae6c 06/24: Make the reader accept bignums, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum 27980e3 21/24: Make ash and lsh handle bignums, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum cca0e79 20/24: Make logb handle bignums,
Tom Tromey <=
- [Emacs-diffs] feature/bignum d0fac17 18/24: Let C modules access bignum values, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum e2a78b0 23/24: Bignum fixes for byte-compiler and bytecode interpreter, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum 45eb3b3 22/24: Use fixnump rather than integerp in some spots, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum cc3d758 24/24: Document bignums, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum 7cb45cd 02/24: Add configury for GMP library, Tom Tromey, 2018/07/13
- [Emacs-diffs] feature/bignum 42fe787 01/24: Rename integerp->fixnum, etc, in preparation for bignums, Tom Tromey, 2018/07/13