emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117144: * calc/calc.el (math-bignum): Handle most-n


From: Leo Liu
Subject: [Emacs-diffs] trunk r117144: * calc/calc.el (math-bignum): Handle most-negative-fixnum.
Date: Sat, 24 May 2014 15:30:09 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117144
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/17556
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Sat 2014-05-24 23:14:47 +0800
message:
  * calc/calc.el (math-bignum): Handle most-negative-fixnum.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/calc/calc.el              calc.el-20091113204419-o5vbwnq5f7feedwu-2306
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-05-23 15:54:44 +0000
+++ b/lisp/ChangeLog    2014-05-24 15:14:47 +0000
@@ -1,3 +1,7 @@
+2014-05-24  Leo Liu  <address@hidden>
+
+       * calc/calc.el (math-bignum): Handle most-negative-fixnum.  (Bug#17556)
+
 2014-05-23  Stefan Monnier  <address@hidden>
 
        * minibuffer.el (completion--sreverse): Remove.

=== modified file 'lisp/calc/calc.el'
--- a/lisp/calc/calc.el 2014-01-01 07:43:34 +0000
+++ b/lisp/calc/calc.el 2014-05-24 15:14:47 +0000
@@ -2773,9 +2773,18 @@
 
 ;; 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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]