unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#14864: bitwise-arithmetic-shift-right is wrong for large shift amounts
@ 2013-07-14 16:08 Göran Weinholt
  2013-07-14 18:54 ` Mark H Weaver
  0 siblings, 1 reply; 2+ messages in thread
From: Göran Weinholt @ 2013-07-14 16:08 UTC (permalink / raw)
  To: 14864

[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]

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@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.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#14864: bitwise-arithmetic-shift-right is wrong for large shift amounts
  2013-07-14 16:08 bug#14864: bitwise-arithmetic-shift-right is wrong for large shift amounts Göran Weinholt
@ 2013-07-14 18:54 ` Mark H Weaver
  0 siblings, 0 replies; 2+ messages in thread
From: Mark H Weaver @ 2013-07-14 18:54 UTC (permalink / raw)
  To: Göran Weinholt; +Cc: 14864-done

Göran Weinholt <goran@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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-14 18:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-14 16:08 bug#14864: bitwise-arithmetic-shift-right is wrong for large shift amounts Göran Weinholt
2013-07-14 18:54 ` Mark H Weaver

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).