<div dir="ltr"><div><div>And as a complement, primitive 14 which is connected to InterpreterPrimitives>>#primitiveBitAnd effectively works for positive receiver and argument up to 32 bits.<br><br></div>Bear in mind that SmallInteger maxVal highBit = 30, so it did make sense to try up to 32 bits.<br>
<br></div>Yet another strategy would be to connect primitive 34 everywhere both in small and large ints...<br><div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/6/21 Nicolas Cellier <span dir="ltr"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Note that some times ago, Andreas and Eliot have added primitives exploiting the ubiquitous possibility of performing 64 bits arithmetic in underlying C language with modern compilers.<br>
<br>So there is also InterpreterPrimitives>>#primitiveBitAndLargeIntegers which works for positive integer receiver and arguments up to 64 bits and is currently connected to primitive 34 in both Interpreter and COG VM.<br>
<br></div>So a possible strategy would be to invoke <primitive: 34> from LargePositiveInteger and fall back to super if failed. That may speed up some operations on "Small" large integers, and will add a bit more delay for "Large" and negative Large integers. Up to you to peek a sufficiently recent VM and test...<br>
</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">2013/6/21 Levente Uzonyi <span dir="ltr"><<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Thu, 20 Jun 2013, Ralph Boland wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am using Squeak 3.11. I assume the same results apply to Squeak 4.4. If not, my apologies.<br>
</blockquote>
<br></div>
LargePositiveInteger >> #bitAnd: is not present in Squeak 4.4.<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
In Squeak if I evaluate:<br>
<br>
1) ((2 << 256) bitAnd: (2 << 128)) ==> 0<br>
2) ((2 << 256) bitAnd: (2 << 128)) class ==> SmallInteger<br>
3) (2 << 128) ==> 680564733841876926926749214863<u></u>536422912<br>
4) ((2 << 128) bitAnd: (2 << 128)) ==> 680564733841876926926749214863<u></u>536422912<br>
<br>
This all looks correct and I care because I need to do <bitAnd:> of some largePositiveIntegers.<br>
<br>
But <LargePositiveInteger>>BitAnd:<u></u>> is:<br>
<br>
"Primitive. Answer an Integer whose bits are the logical AND of the<br>
receiver's bits and those of the argument. Fail if the receiver or argument<br>
is greater than 32 bits. See Object documentation whatIsAPrimitive."<br>
<primitive: 14><br>
self halt. "I ADDED THE HALT"<br>
^ super bitAnd: anInteger<br>
<br>
The way I see it <LargePositiveInteger>>BitAnd:<u></u>> is always going to fail and thus invoke its super version<br>
(<LargePositiveInteger>><u></u>BitAnd:>) and this is what I see when I run the code; i.e. I hit the halt.<br>
<br>
So why have <LargePositiveInteger>>BitAnd:<u></u>> method at all?<br>
</blockquote>
<br></div>
As the comment says: primitive 14 works for nonnegative SmallIntegers and all LargePositiveIntegers which can be represented in 4 bytes, so all values up to 4294967295.<br>
<br>
In your image the following expression should use the primitive:<br>
<br>
4294967295 bitAnd: 1<br>
<br>
In this case the primitive should fail:<br>
<br>
4294967296 bitAnd: 1<span><font color="#888888"><br>
<br>
<br>
Levente</font></span><div><div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Ditto for the other bit operations.<br>
<br>
Ralph Boland<br>
<br>
</blockquote>
</div></div><br><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>