GNU bug report logs - #43764
Calc shift right broken

Previous Next

Package: emacs;

Reported by: Vincent Belaïche <vincent.b.1 <at> hotmail.fr>

Date: Fri, 2 Oct 2020 15:29:02 UTC

Severity: normal

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: Mattias Engdegård <mattiase <at> acm.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Vincent Belaïche <vincent.b.1 <at> hotmail.fr>, 43764 <at> debbugs.gnu.org
Subject: bug#43764: Calc shift right broken
Date: Thu, 8 Oct 2020 14:24:02 +0200
6 okt. 2020 kl. 03.28 skrev Lars Ingebrigtsen <larsi <at> gnus.org>:

> On the other hand, I don't know what people use Calc for here. If
> people are going "I wonder what would happen on a 32-bit machine if I
> were to do this shift operation", then it'd be something else...

Yes, we should be defending the users of Emacs, not Emacs itself.

What about a narrower change: clip the value after shifting right instead of before?

Vincent, would you be happy with the patch below, or do you think a more fundamental change is required?

--- a/lisp/calc/calc-bin.el
+++ b/lisp/calc/calc-bin.el
@@ -375,7 +375,7 @@ calcFunc-lsh
                 (Math-lessp w n))
             0)
            ((< n 0)
-            (math-quotient (math-clip a w) (math-power-of-2 (- n))))
+             (math-clip (math-quotient a (math-power-of-2 (- n))) w))
            (t
             (math-clip (math-mul a (math-power-of-2 n)) w))))))
 





This bug report was last modified 4 years and 196 days ago.

Previous Next


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