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

bitwise shift is inconsistent on int #4341

Open
p6rt opened this issue Jun 23, 2015 · 6 comments
Open

bitwise shift is inconsistent on int #4341

p6rt opened this issue Jun 23, 2015 · 6 comments

Comments

@p6rt
Copy link

@p6rt p6rt commented Jun 23, 2015

Migrated from rt.perl.org#125466 (status was 'open')

Searchable as RT125466$

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Jun 23, 2015

From @Tux

$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 16'
-9223372036854775808
-140737488355328
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 32'
-9223372036854775808
-2147483648
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 63'
-9223372036854775808
-1
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 64'
-9223372036854775808
-9223372036854775808 <===== plain wrong
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -32'
-9223372036854775808
-39614081257132168796771975168
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -64'
-9223372036854775808
-170141183460469231731687303715884105728

$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 16'
9223372036854775807
140737488355327
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 32'
9223372036854775807
2147483647
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 63'
9223372036854775807
0
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 64'
9223372036854775807
9223372036854775807 <= PLAIN WRONG
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -2'
9223372036854775807
36893488147419103228
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -32'
9223372036854775807
39614081257132168792477007872
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +< 2'
9223372036854775807
-4 <= WHAT?
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +< -2'
9223372036854775807
2305843009213693951

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Sep 17, 2017

From @AlexDaniel

Plain-wrongs and WHATs print different results today. Bisectable points at rakudo/rakudo@242baf2

I think we now only need tests for this ticket.

On 2015-06-23 09​:05​:43, hmbrand wrote​:

$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 16'
-9223372036854775808
-140737488355328
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 32'
-9223372036854775808
-2147483648
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 63'
-9223372036854775808
-1
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 64'
-9223372036854775808
-9223372036854775808 <=====
plain wrong
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -32'
-9223372036854775808
-39614081257132168796771975168
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -64'
-9223372036854775808
-170141183460469231731687303715884105728

$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 16'
9223372036854775807
140737488355327
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 32'
9223372036854775807
2147483647
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 63'
9223372036854775807
0
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 64'
9223372036854775807
9223372036854775807 <=
PLAIN WRONG
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -2'
9223372036854775807
36893488147419103228
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -32'
9223372036854775807
39614081257132168792477007872
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +< 2'
9223372036854775807
-4 <=
WHAT?
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +< -2'
9223372036854775807
2305843009213693951

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Sep 17, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Oct 8, 2017

From @zoffixznet

On Sun, 17 Sep 2017 15​:17​:47 -0700, alex.jakimenko@​gmail.com wrote​:

Plain-wrongs and WHATs print different results today. Bisectable
points at
rakudo/rakudo@242baf2

I think we now only need tests for this ticket.

On 2015-06-23 09​:05​:43, hmbrand wrote​:

$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 16'
-9223372036854775808
-140737488355328
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 32'
-9223372036854775808
-2147483648
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 63'
-9223372036854775808
-1
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> 64'
-9223372036854775808
-9223372036854775808 <=====
plain wrong
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -32'
-9223372036854775808
-39614081257132168796771975168
$ perl6 -e'my int $i = int.Range.min; say $i; say $i +> -64'
-9223372036854775808
-170141183460469231731687303715884105728

$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 16'
9223372036854775807
140737488355327
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 32'
9223372036854775807
2147483647
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 63'
9223372036854775807
0
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> 64'
9223372036854775807
9223372036854775807 <=
PLAIN WRONG
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -2'
9223372036854775807
36893488147419103228
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +> -32'
9223372036854775807
39614081257132168792477007872
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +< 2'
9223372036854775807
-4 <=
WHAT?
$ perl6 -e'my int $i = int.Range.max; say $i; say $i +< -2'
9223372036854775807
2305843009213693951

For some of these that OP pointed out as questionable I get the
same results as in C. For others, the bug still exists, where it
just returns an Int instead of overflowing​: https://irclog.perlgeek.de/perl6/2017-10-08#i_15272553

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Oct 8, 2017

From @zoffixznet

Tests were added in https://github.com/perl6/roast/pull/344/files

There are three fudges where it's unknown what the proper behaviour should be (overflow or switch to Int?).

Someone Who Knows should review them and unfudge/correct.

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Mar 5, 2018

From @zoffixznet

On Sat, 07 Oct 2017 23​:35​:26 -0700, cpan@​zoffix.com wrote​:

Tests were added in https://github.com/perl6/roast/pull/344/files

There are three fudges where it's unknown what the proper behaviour
should be (overflow or switch to Int?).

Someone Who Knows should review them and unfudge/correct.

Some comments on this​: https://irclog.perlgeek.de/perl6-dev/2018-03-05#i_15887265

  * TimToady thinks people who are writing crypto codes want ways to keep everything native, if we make it default the other way

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.