* bug#17556: 24.4.50; fix math-bignum @ 2014-05-23 4:46 Leo Liu 2014-05-23 7:33 ` Andreas Schwab 2014-05-24 15:19 ` Leo Liu 0 siblings, 2 replies; 5+ messages in thread From: Leo Liu @ 2014-05-23 4:46 UTC (permalink / raw) To: 17556 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) ^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#17556: 24.4.50; fix math-bignum 2014-05-23 4:46 bug#17556: 24.4.50; fix math-bignum Leo Liu @ 2014-05-23 7:33 ` Andreas Schwab 2014-05-23 8:23 ` martin rudalics 2014-05-23 9:44 ` Leo Liu 2014-05-24 15:19 ` Leo Liu 1 sibling, 2 replies; 5+ messages in thread From: Andreas Schwab @ 2014-05-23 7:33 UTC (permalink / raw) To: Leo Liu; +Cc: 17556 Leo Liu <sdl.web@gmail.com> writes: > + (math-sub (cons 'bigneg (math-bignum-big (- (1+ a)))) aka (- 1 a) Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#17556: 24.4.50; fix math-bignum 2014-05-23 7:33 ` Andreas Schwab @ 2014-05-23 8:23 ` martin rudalics 2014-05-23 9:44 ` Leo Liu 1 sibling, 0 replies; 5+ messages in thread From: martin rudalics @ 2014-05-23 8:23 UTC (permalink / raw) To: Andreas Schwab, Leo Liu; +Cc: 17556 >> + (math-sub (cons 'bigneg (math-bignum-big (- (1+ a)))) > > aka (- 1 a) Hmmm... martin ^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#17556: 24.4.50; fix math-bignum 2014-05-23 7:33 ` Andreas Schwab 2014-05-23 8:23 ` martin rudalics @ 2014-05-23 9:44 ` Leo Liu 1 sibling, 0 replies; 5+ messages in thread From: Leo Liu @ 2014-05-23 9:44 UTC (permalink / raw) To: Andreas Schwab; +Cc: 17556 On 2014-05-23 09:33 +0200, Andreas Schwab wrote: > aka (- 1 a) aka most-positive-fixnum ;) Leo ^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#17556: 24.4.50; fix math-bignum 2014-05-23 4:46 bug#17556: 24.4.50; fix math-bignum Leo Liu 2014-05-23 7:33 ` Andreas Schwab @ 2014-05-24 15:19 ` Leo Liu 1 sibling, 0 replies; 5+ messages in thread From: Leo Liu @ 2014-05-24 15:19 UTC (permalink / raw) To: 17556-done Fixed in 24.5 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-05-24 15:19 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-05-23 4:46 bug#17556: 24.4.50; fix math-bignum Leo Liu 2014-05-23 7:33 ` Andreas Schwab 2014-05-23 8:23 ` martin rudalics 2014-05-23 9:44 ` Leo Liu 2014-05-24 15:19 ` Leo Liu
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).