[perl #109740] [BUG] Four extra bits after +& operation in Rakudo
Carl Mäsak <perl6-bugs-followup <at> perl.org>
2012-02-03 13:54:19 GMT
# New Ticket Created by "Carl Mäsak"
# Please include the string: [perl #109740]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=109740 >
<grondilu> nom: my ($x, $y) = (2**30, 1); printf "%32b\n", +^$x +& $y;
<p6eval> nom acbec8:
OUTPUT«1111000000000000000000000000000000000000000000000000000000000001»
<grondilu> where do those four bits come from??
<grondilu> niecza: my ($x, $y) = (2**30, 1); printf "%32b", +^$x +& $y;
<p6eval> niecza v13-389-g852f0ff: OUTPUT« 1»
<moritz> grondilu: I just realized, libtommath (which we use for
storing bigints) uses 28bit "digits"
<moritz> grondilu: so there might indeed a bug in there somewhere
<grondilu> oh, this explains a lot
<moritz> grondilu: feel free to submit as rakudobug (or even fix if you want
<grondilu> I don't know how to. Someone please do it.
* masak submits rakudobug
<moritz> libtommath stores sign separately from the rest of the bits,
which is why we need to emulate 2's complement math
<moritz> and that part might be buggy