[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## bug#17556: 24.4.50; fix math-bignum

**From**: |
Leo Liu |

**Subject**: |
bug#17556: 24.4.50; fix math-bignum |

**Date**: |
Fri, 23 May 2014 12:46:05 +0800 |

Due to integer overflow (math-bignum most-negative-fixnum) is incorrect.
Any objection if I fix it like in this patch:
=== modified file 'lisp/calc/calc.el'
--- lisp/calc/calc.el 2014-01-01 07:43:34 +0000
+++ lisp/calc/calc.el 2014-05-23 04:42:18 +0000
@@ -2773,9 +2773,15 @@
;; 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: (- most-negative-fixnum) is most-negative-fixnum
+ (math-sub (cons 'bigneg (math-bignum-big (- (1+ a))))
+ 1))
+ (t
+ (cons 'bigneg (math-bignum-big (- a))))))
(defun math-bignum-big (a) ; [L s]
(if (= a 0)

**bug#17556: 24.4.50; fix math-bignum**,
*Leo Liu* **<=**