bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: David Ongaro
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
User-agent: Microsoft-MacOutlook/16.37.20051002

On 15.05.20, 03:19, "Mattias Engdegård" <mattiase@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".







reply via email to

[Prev in Thread] Current Thread [Next in Thread]