--- Begin Message ---
Subject: |
bitwise-arithmetic-shift-right is wrong for large shift amounts |
Date: |
Sun, 14 Jul 2013 18:08:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) |
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 <address@hidden>
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.
pgpGRq4IYBkmu.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#14864: bitwise-arithmetic-shift-right is wrong for large shift amounts |
Date: |
Sun, 14 Jul 2013 14:54:24 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Göran Weinholt <address@hidden> 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
--- End Message ---