diff options
author | Leo Liu <sdl.web@gmail.com> | 2014-05-24 23:14:47 +0800 |
---|---|---|
committer | Leo Liu <sdl.web@gmail.com> | 2014-05-24 23:14:47 +0800 |
commit | ec774634839b0d6ea52f96e272954bdbb5cd9726 (patch) | |
tree | 2c151b4c0f5f9191e0a56b09049dd096cc19a69c /lisp | |
parent | c94e3311ecf51bf3c6017ab4028debcae2a5dd6e (diff) | |
download | emacs-ec774634839b0d6ea52f96e272954bdbb5cd9726.tar.gz |
* calc/calc.el (math-bignum): Handle most-negative-fixnum.
Fixes: debbugs:17556
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ChangeLog | 4 | ||||
-rw-r--r-- | lisp/calc/calc.el | 15 |
2 files changed, 16 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7c2b1ec5ad6..b786027f76d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2014-05-24 Leo Liu <sdl.web@gmail.com> + + * calc/calc.el (math-bignum): Handle most-negative-fixnum. (Bug#17556) + 2014-05-23 Stefan Monnier <monnier@iro.umontreal.ca> * minibuffer.el (completion--sreverse): Remove. diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el index ba1c7de9967..04d852e5cb3 100644 --- a/lisp/calc/calc.el +++ b/lisp/calc/calc.el @@ -2773,9 +2773,18 @@ largest Emacs integer.") ;; Coerce integer A to be a bignum. [B S] (defun math-bignum (a) - (if (>= a 0) - (cons 'bigpos (math-bignum-big a)) - (cons 'bigneg (math-bignum-big (- a))))) + (cond + ((>= a 0) + (cons 'bigpos (math-bignum-big a))) + ((= a most-negative-fixnum) + ;; Note: cannot get the negation directly because + ;; (- most-negative-fixnum) is most-negative-fixnum. + ;; + ;; most-negative-fixnum := -most-positive-fixnum - 1 + (math-sub (cons 'bigneg (math-bignum-big most-positive-fixnum)) + 1)) + (t + (cons 'bigneg (math-bignum-big (- a)))))) (defun math-bignum-big (a) ; [L s] (if (= a 0) |