<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 29, 2015 at 1:33 PM, Nicolas Cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Before I forget it, I have this trick ready for a year or so that<br>
might serve in my LargeInteger plugin which use int64 a lot.<br>
<br>
If SmallInteger are on 31 bits, then the 34 most significant bits of<br>
the int64 must be the same...<br>
since we are tricky, we just test 33 bits:<br>
    (((usqLong)(x)) + 0x40000000ULL) &amp; 0xFFFFFFFF80000000ULL == 0<br>
<br>
And when SmallInt is 61bits long (Spur64), the 4 most significant bits<br>
must be the same<br>
we just test 3 bits:<br>
    (((usqLong)(x)) + 0x1000000000000000UL) &amp; 0xE000000000000000UL == 0<br>
<br>
Indeed:<br>
    2r0000 + 1 -&gt; 0001<br>
    2r1111 + 1 -&gt; 0000<br>
Any other combination will be &gt; 1 and have one of the most significant<br>
3 bits != 0<br>
So we just have to test the first 3 bits<br></blockquote><div><br></div><div>And we&#39;re using the same trick on the ARM 32x32=&gt;64 multiply.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It&#39;s almost how #isIntegerValue: is done currently in Spur 64 but with<br>
one more op and a test on 4 most significant bits...<br>
 (intValue &gt;&gt; 60 + 1 bitAnd: 16rF) &lt;= 1 </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Nicolas</font></span></blockquote></div><div><br></div>-- <br><div class="gmail_signature">best,<div>Eliot</div></div>
</div></div>