<div><div dir="auto">But that means that at some point a bit operation (bitShift, bitOr, bitAnd) answers a LargeInteger that actually fits in a SmallInteger, right? That should never happen, because for example equality fails.</div></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 24 Jun 2020 at 9:28 PM, Juan Vuletich <<a href="mailto:juan@jvuletich.org">juan@jvuletich.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><u></u>
<div bgcolor="#ffffff" text="#000000"></div><div bgcolor="#ffffff" text="#000000">
On 6/23/2020 10:58 AM, Luciano Notarfrancesco via Cuis-dev wrote:
<blockquote type="cite">
<div>
<div dir="auto">Sorry, should be whileTrue there...</div>
</div>
<div><br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, 23 Jun 2020 at 8:57
PM, Luciano Notarfrancesco <<a href="mailto:luchiano@gmail.com" target="_blank">luchiano@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">
<div dir="auto">Try this in a workspace:</div>
<div dir="auto"><br>
</div>
<div dir="auto">[a _ (1 << 60) atRandom.</div>
<div dir="auto">b _ (a bitReverse: 64) bitReverse: 64.</div>
<div dir="auto">a = b] whileFalse</div>
<div dir="auto"><br>
</div>
<div dir="auto">I tested it in the latest image with a
recent cog spur x64 VM. The loop stops with a ‘b’ that is
a LargePositiveInteger but it actually fits in a
SmallInteger and it is equal to ‘a’. I don’t have time to
debug it until the weekend but I thought someone might
find it amusing.</div>
</blockquote>
</div>
</div>
</blockquote>
<br></div><div bgcolor="#ffffff" text="#000000">
Well, this was fun!<br>
<br>
When you find the problem (the primitive in #bitShiftMagnitude:
answers the receiver if the argument is zero, without reducing it to
SmallInteger as appropriate), and you try to fix it, then, when you
want to write a test that fails without the fix, you can not make it
fail!<br>
<br>
The problem only happens when #bitReverse: gets jitted by the Cog
VM, and that requires a few runs to happen. Hence, the test loops a
few times, doing exactly the same.<br>
<br>
Please take a look.<br>
<br>
Cheers,<br>
<pre cols="72" style="font-family:monospace">--
Juan Vuletich
<a href="http://www.cuis-smalltalk.org" target="_blank" style="font-family:monospace">www.cuis-smalltalk.org</a>
<a href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev" target="_blank" style="font-family:monospace">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a>
<a href="https://github.com/jvuletich" target="_blank" style="font-family:monospace">https://github.com/jvuletich</a>
<a href="https://www.linkedin.com/in/juan-vuletich-75611b3" target="_blank" style="font-family:monospace">https://www.linkedin.com/in/juan-vuletich-75611b3</a>
@JuanVuletich</pre>
</div>
</blockquote></div></div>