aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorLeo Liu <[email protected]>2014-06-27 12:10:04 +0800
committerLeo Liu <[email protected]>2014-06-27 12:10:04 +0800
commit708dc66d7b8dd5bd4f66558cd6a61502b6b68b43 (patch)
treea85566266437747dbdebfcb9819171ac85938c01 /lisp
parent340d54a195785ff94de2b274fd71a75a71908af2 (diff)
Backport fix for http://debbugs.gnu.org/17556 from trunk
* lisp/calc/calc.el (math-bignum): Handle most-negative-fixnum.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/calc/calc.el15
2 files changed, 16 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a2cb2845bc..dcbb027e94 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
+2014-06-27 Leo Liu <[email protected]>
+
+ * calc/calc.el (math-bignum): Handle most-negative-fixnum. (Bug#17556)
+
2014-06-27 Glenn Morris <[email protected]>
* net/eww.el (eww-mode) <eww-current-title>: Make local. (Bug#17860)
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index ba1c7de996..04d852e5cb 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)