diff options
| author | Paul Eggert | 2018-08-19 01:22:08 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-08-19 01:22:25 -0700 |
| commit | 47b7a5bd492e92dda928843e28a707b9682cb32f (patch) | |
| tree | 90c26ba233152114aa308fe19a51f38c52735223 /test/src | |
| parent | 06b5bcd639bf97fc77dc89dd52f136d4f262e888 (diff) | |
| download | emacs-47b7a5bd492e92dda928843e28a707b9682cb32f.tar.gz emacs-47b7a5bd492e92dda928843e28a707b9682cb32f.zip | |
Add bignum support to expt
Problem and initial solution reported by Andy Moreton in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00503.html
* doc/lispref/numbers.texi (Math Functions): expt integer
overflow no longer causes truncation; it now signals an error
since bignum overflow is a big deal.
* src/floatfns.c (Fexpt): Support bignum arguments.
* test/src/floatfns-tests.el (bignum-expt): New test.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/floatfns-tests.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/src/floatfns-tests.el b/test/src/floatfns-tests.el index 43a2e278290..e4caaa1e49b 100644 --- a/test/src/floatfns-tests.el +++ b/test/src/floatfns-tests.el | |||
| @@ -42,6 +42,15 @@ | |||
| 42 | (should (= most-positive-fixnum | 42 | (should (= most-positive-fixnum |
| 43 | (- (abs most-negative-fixnum) 1)))) | 43 | (- (abs most-negative-fixnum) 1)))) |
| 44 | 44 | ||
| 45 | (ert-deftest bignum-expt () | ||
| 46 | (dolist (n (list most-positive-fixnum (1+ most-positive-fixnum) | ||
| 47 | most-negative-fixnum (1- most-negative-fixnum) | ||
| 48 | -2 -1 0 1 2)) | ||
| 49 | (should (= (expt n 0) 1)) | ||
| 50 | (should (= (expt n 1) n)) | ||
| 51 | (should (= (expt n 2) (* n n))) | ||
| 52 | (should (= (expt n 3) (* n n n))))) | ||
| 53 | |||
| 45 | (ert-deftest bignum-logb () | 54 | (ert-deftest bignum-logb () |
| 46 | (should (= (+ (logb most-positive-fixnum) 1) | 55 | (should (= (+ (logb most-positive-fixnum) 1) |
| 47 | (logb (+ most-positive-fixnum 1))))) | 56 | (logb (+ most-positive-fixnum 1))))) |