GNU bug report logs - #41279
26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1

Previous Next

Package: emacs;

Reported by: David Ongaro <david.ongaro <at> hamburg.de>

Date: Fri, 15 May 2020 04:54:02 UTC

Severity: normal

Found in version 26.3

Done: Mattias Engdegård <mattiase <at> acm.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: David Ongaro <david.ongaro <at> hamburg.de>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: 41279 <at> debbugs.gnu.org
Subject: bug#41279: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1 
Date: Fri, 15 May 2020 10:44:07 -0700
On 15.05.20, 03:19, "Mattias Engdegård" <mattiase <at> acm.org> wrote:

> Thank you for reporting this. It seems that Calc first simplifies gcd(0,n) to n and then computes sum(n,n,-1,-1) = -1.
> We could either make gcd(0,x)=gcd(x,0)=|x|, or try preventing sum from simplifying its operand first, or both.
> For the smallest possible change, what about the hack below?

I see, so the simplest reproduction of the bug doesn't involve the sum, but just the evaluation of gcd(0, x) or gcd(x, 0). Your fix seems sensible to me, I don't see why you consider it a 'hack'. The simplification gcd(0, x)=gcd(x, 0)=abs(x) seems legit and matches the gcd definition "The largest positive integer that divides each of the integers".






This bug report was last modified 5 years and 10 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.