aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMattias EngdegÄrd2020-05-15 14:52:50 +0200
committerMattias EngdegÄrd2020-05-15 20:15:36 +0200
commit60cd6cce55744e8d3ae844e0602c9dd268dc4bc3 (patch)
tree168fe989cb322c487b017f4f4ed293be6a40cb5c /lisp
parentb76cdd0c1a7978decc0c1044ad23ecc9432c526a (diff)
downloademacs-60cd6cce55744e8d3ae844e0602c9dd268dc4bc3.tar.gz
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')
-rw-r--r--lisp/calc/calc-comb.el4
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 @@
241 (calcFunc-gcd (math-neg a) b)) 241 (calcFunc-gcd (math-neg a) b))
242 ((Math-looks-negp b) 242 ((Math-looks-negp b)
243 (calcFunc-gcd a (math-neg b))) 243 (calcFunc-gcd a (math-neg b)))
244 ((Math-zerop a) b) 244 ((Math-zerop a) (math-abs b))
245 ((Math-zerop b) a) 245 ((Math-zerop b) (math-abs a))
246 ((and (Math-ratp a) 246 ((and (Math-ratp a)
247 (Math-ratp b)) 247 (Math-ratp b))
248 (math-make-frac (math-gcd (if (eq (car-safe a) 'frac) (nth 1 a) a) 248 (math-make-frac (math-gcd (if (eq (car-safe a) 'frac) (nth 1 a) a)