diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2020-05-15 14:52:50 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2020-05-15 20:15:36 +0200 |
commit | 60cd6cce55744e8d3ae844e0602c9dd268dc4bc3 (patch) | |
tree | 168fe989cb322c487b017f4f4ed293be6a40cb5c /lisp/calc/calc-comb.el | |
parent | b76cdd0c1a7978decc0c1044ad23ecc9432c526a (diff) | |
download | emacs-60cd6cce55744e8d3ae844e0602c9dd268dc4bc3.tar.gz emacs-60cd6cce55744e8d3ae844e0602c9dd268dc4bc3.tar.bz2 emacs-60cd6cce55744e8d3ae844e0602c9dd268dc4bc3.zip |
Calc: GCD(0,x)=GCD(x,0)=|x|, not x (bug#41279)
Reported by David Ongaro.
* lisp/calc/calc-comb.el (calcFunc-gcd): Fix GCD simplification.
* test/lisp/calc/calc-tests.el (calc-gcd, calc-sum-gcd): New tests.
Diffstat (limited to 'lisp/calc/calc-comb.el')
-rw-r--r-- | lisp/calc/calc-comb.el | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lisp/calc/calc-comb.el b/lisp/calc/calc-comb.el index d4562a0cc86..c5d4d0837e7 100644 --- a/lisp/calc/calc-comb.el +++ b/lisp/calc/calc-comb.el @@ -241,8 +241,8 @@ (calcFunc-gcd (math-neg a) b)) ((Math-looks-negp b) (calcFunc-gcd a (math-neg b))) - ((Math-zerop a) b) - ((Math-zerop b) a) + ((Math-zerop a) (math-abs b)) + ((Math-zerop b) (math-abs a)) ((and (Math-ratp a) (Math-ratp b)) (math-make-frac (math-gcd (if (eq (car-safe a) 'frac) (nth 1 a) a) |