Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigint rshift op is 1s complement, should be 2s complement #2985

Closed
p6rt opened this issue Nov 30, 2012 · 4 comments
Closed

bigint rshift op is 1s complement, should be 2s complement #2985

p6rt opened this issue Nov 30, 2012 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Nov 30, 2012

Migrated from rt.perl.org#115958 (status was 'resolved')

Searchable as RT115958$

@p6rt
Copy link
Author

p6rt commented Nov 30, 2012

From @skids

Int should behave as a two's complement number with infinitely extended
sign bits, per spec. As such -1 is an identity value for right shift,
as is 0. Currently -1 +> 1 is 0 in rakudo, for example, where it should
be -1.

A possible fix is at https://gist.github.com/4178797. It has not been
roasted.

Test​:
is (-4..-1 X+> 1..3), (-2,-1,-1,-2,-1 xx 8), "Right shift is two's complement"

@p6rt
Copy link
Author

p6rt commented Oct 21, 2014

From @usev6

This seems to work now​:

$ perl6-m -e 'say -1 +> 1'
-1

$ perl6-p -e 'say -1 +> 1'
-1

$ perl6-j -e 'say -1 +> 1'
-1

skidd++ added a test to S03-operators/bit.t with the following commit​: Raku/roast@3f8942b

I'm closing this ticket now.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 21, 2014

From @usev6

This seems to work now​:

$ perl6-m -e 'say -1 +> 1'
-1

$ perl6-p -e 'say -1 +> 1'
-1

$ perl6-j -e 'say -1 +> 1'
-1

skidd++ added a test to S03-operators/bit.t with the following commit​: Raku/roast@3f8942b

I'm closing this ticket now.

@p6rt p6rt closed this as completed Oct 21, 2014
@p6rt
Copy link
Author

p6rt commented Oct 21, 2014

@usev6 - Status changed from 'new' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant