unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: "Vincent Belaïche" <vincent.b.1@hotmail.fr>, 43764@debbugs.gnu.org
Subject: bug#43764: Calc shift right broken
Date: Thu, 8 Oct 2020 14:24:02 +0200	[thread overview]
Message-ID: <4648BF2F-8507-4D39-85F1-1C40C0E8BFC2@acm.org> (raw)
In-Reply-To: <87wo04nnvr.fsf@gnus.org>

6 okt. 2020 kl. 03.28 skrev Lars Ingebrigtsen <larsi@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))))))
 






  reply	other threads:[~2020-10-08 12:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-02 15:28 bug#43764: Calc shift right broken Vincent Belaïche
2020-10-02 20:49 ` Mattias Engdegård
2020-10-05  8:12   ` Lars Ingebrigtsen
2020-10-05 10:34     ` Mattias Engdegård
2020-10-06  1:28       ` Lars Ingebrigtsen
2020-10-08 12:24         ` Mattias Engdegård [this message]
2020-10-09 15:29           ` Mattias Engdegård
2020-10-09 15:34         ` Vincent Belaïche
2020-10-10 16:24           ` Mattias Engdegård
2020-10-10 16:31             ` Mattias Engdegård
2020-10-13  9:56           ` Mattias Engdegård
2020-11-04 11:14             ` Vincent Belaïche
2020-11-04 11:54               ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4648BF2F-8507-4D39-85F1-1C40C0E8BFC2@acm.org \
    --to=mattiase@acm.org \
    --cc=43764@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=vincent.b.1@hotmail.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).