GNU bug report logs - #14864
bitwise-arithmetic-shift-right is wrong for large shift amounts

Previous Next

Package: guile;

Reported by: Göran Weinholt <goran <at> weinholt.se>

Date: Sun, 14 Jul 2013 16:15:01 UTC

Severity: normal

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14864 in the body.
You can then email your comments to 14864 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#14864; Package guile. (Sun, 14 Jul 2013 16:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Göran Weinholt <goran <at> weinholt.se>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sun, 14 Jul 2013 16:15:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Göran Weinholt <goran <at> weinholt.se>
To: bug-guile <at> gnu.org
Subject: bitwise-arithmetic-shift-right is wrong for large shift amounts
Date: Sun, 14 Jul 2013 18:08:55 +0200
[Message part 1 (text/plain, inline)]
Hello schemers,

bitwise-arithmetic-shift-right from (rnrs) is wrong for ridiculously
large shift amounts:

scheme@(guile-user)> (import (rnrs))
scheme@(guile-user)> (bitwise-arithmetic-shift-right -2 (+ (greatest-fixnum) 1))
$1 = -2

The correct result is -1. Tested on an amd64 system with
guile-2.0.9.20-10454-dirty. Here are a few more failing cases, if it
helps:

(bitwise-arithmetic-shift-right
  -1939573486025768832
  1842615318141600354)
=>
-112898036
; *** failed ***
; expected result: -1

(bitwise-arithmetic-shift-right
  1344211617424411880
  1877595747324902264)
=>
18
; *** failed ***
; expected result: 0

(bitwise-arithmetic-shift-right
  -1152921504606846979
  88553614889043251)
=>
-513
; *** failed ***
; expected result: -1

(bitwise-arithmetic-shift-right
  -870600743868926059
  1508151148)
=>
-49488
; *** failed ***
; expected result: -1

Regards,

-- 
Göran Weinholt <goran <at> weinholt.se>
13             MR. JAKES:  I think our economy was based on
14 industrial process.
15             JUSTICE SCALIA:  It was based on horses, for
16 Pete's sake.
[Message part 2 (application/pgp-signature, inline)]

Reply sent to Mark H Weaver <mhw <at> netris.org>:
You have taken responsibility. (Sun, 14 Jul 2013 18:55:04 GMT) Full text and rfc822 format available.

Notification sent to Göran Weinholt <goran <at> weinholt.se>:
bug acknowledged by developer. (Sun, 14 Jul 2013 18:55:07 GMT) Full text and rfc822 format available.

Message #10 received at 14864-done <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: Göran Weinholt <goran <at> weinholt.se>
Cc: 14864-done <at> debbugs.gnu.org
Subject: Re: bug#14864: bitwise-arithmetic-shift-right is wrong for large
 shift amounts
Date: Sun, 14 Jul 2013 14:54:24 -0400
Göran Weinholt <goran <at> weinholt.se> writes:

> bitwise-arithmetic-shift-right from (rnrs) is wrong for ridiculously
> large shift amounts:
>
> scheme@(guile-user)> (import (rnrs))
> scheme@(guile-user)> (bitwise-arithmetic-shift-right -2 (+ (greatest-fixnum) 1))
> $1 = -2
>
> The correct result is -1.

Thanks for the report.  Now fixed in stable-2.0.

http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commitdiff;h=7e8166f5bdb526c021c826943aaf050134cccc83

    Mark




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 12 Aug 2013 11:24:03 GMT) Full text and rfc822 format available.

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

Previous Next


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