On Tue, 09 May 2017 09:49:37 -0700, c...@tilmes.org wrote:
> <curt_> m: my $i = -0x8000000000000000; say ($i div 2**12) == ($i +> 12) ??
> 'good' !! 'bad';
> <camelia> rakudo-moar 6bb1b5: OUTPUT: «good␤»
> <curt_> m: my $i = -0x8000000000000000; say ($i div 2**37) == ($i +> 37) ??
> 'good' !! 'bad';
> <camelia> rakudo-moar 6bb1b5: OUTPUT: «bad␤»
> <curt_> m: my $i = -0x8000000000000000; say ($i div 2**23) == ($i +> 23) ??
> 'good' !! 'bad';
> <camelia> rakudo-moar 6bb1b5: OUTPUT: «good␤»
> <curt_> m: my $i = -0x8000000000000000; say ($i div 2**42) == ($i +> 42) ??
> 'good' !! 'bad';
> <camelia> rakudo-moar 6bb1b5: OUTPUT: «bad␤»
> <TimToady> loks like a bug
> <TimToady> at the 32-bit boundary
> <TimToady> m: my $i = -0x8000000000000000; say ($i +> 31)
> <camelia> rakudo-moar 6bb1b5: OUTPUT: «-4294967296␤»
> <TimToady> m: my $i = -0x8000000000000000; say ($i +> 32)
> <camelia> rakudo-moar 6bb1b5: OUTPUT: «-1␤»
> <TimToady> please report bug


Looking at the source code, this behaviour is due to a kludge to fix 
RT#126942[^1],
according to which long bit shifts of negative integers should always produce -1

I'm not sure where the value of 32 bits came into play, other than it's the 
value
where RT#126942's bug came around.

[1] https://rt.perl.org/Ticket/Display.html?id=126942
[2] https://github.com/rakudo/rakudo/blob/6435933/src/core/Int.pm#L412

Reply via email to