unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Zefram <zefram@fysh.org>
Cc: 21901@debbugs.gnu.org
Subject: bug#21901: bit shift wrong on maximal right shift
Date: Mon, 20 Jun 2016 18:02:50 +0200	[thread overview]
Message-ID: <87porbg85x.fsf@pobox.com> (raw)
In-Reply-To: <20151113102203.GL13455@fysh.org> (zefram@fysh.org's message of "Fri, 13 Nov 2015 10:22:03 +0000")

On Fri 13 Nov 2015 11:22, Zefram <zefram@fysh.org> writes:

> With Guile 2.0.11:
>
> scheme@(guile-user)> (ash 123 (ash -1 63))
> $1 = 123
>
> Correct result would of course be zero.  Problem only occurs for
> exactly this shift distance: one bit less produces the right answer.
> Problem also occurs on Guile 1.8.8.  Looking at the implementation,
> the problem is attributable to the negation of the shift distance,
> which in twos-complement fails to produce the expected positive result.
>
> Note the resemblance to bug #14864, fixed in 2.0.10.  This bug is of
> very similar form, but is distinct.  The test cases of #14864 pass for
> me on the 2.0.11 that shows the problem with a 2^63 bit shift.  My bug
> does occur with the rnrs bitwise-arithmetic-shift-right, which was used
> in #14864, as well as with ash.

Fascinating, thank you!  Also occurs on 2.1.3.

Andy





  reply	other threads:[~2016-06-20 16:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-13 10:22 bug#21901: bit shift wrong on maximal right shift Zefram
2016-06-20 16:02 ` Andy Wingo [this message]
2018-10-14  9:40 ` Mark H Weaver
2018-10-20 22:27 ` Mark H Weaver

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/guile/

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

  git send-email \
    --in-reply-to=87porbg85x.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=21901@debbugs.gnu.org \
    --cc=zefram@fysh.org \
    /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.
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).