<div dir="ltr">Hi Andres,<div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 18, 2017 at 1:52 AM, Andres Valloud <span dir="ltr"><<a href="mailto:avalloud@smalltalk.comcastbiz.net" target="_blank">avalloud@smalltalk.comcastbiz.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br>
Yes, the SqR initials are mine.  That's too bad about the comments, at the very least there should be something like this:<br>
<br>
"This code performs a multiplication by 1664525 mod 2^28 without overflowing into large integers."</blockquote><div><br></div><div>Thanks.  I'll update the primitives appropriately.  Could you supply a reference both for the technique and the choice of  1664525 in particular?  I'd like to include that info in the comments too.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">On 4/18/17 1:48 , Levente Uzonyi wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
The methods in SmallInteger and LargePositiveInteger have the initials<br>
SqR (that's yours IIRC), but they have no comment.<br>
The variant in String is originally from 2001 and has never had that<br>
comment.<br>
<br>
Levente<br>
<br>
On Mon, 17 Apr 2017, Andres Valloud wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
On 4/17/17 16:45 , Eliot Miranda wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
FYI, hash multiply is<br>
hashMultiply<br>
| low |<br>
low := self bitAnd: 16383.<br>
^(16r260D * low + ((16r260D * (self bitShift: -14) + (16r0065 * low)<br>
bitAnd: 16383) * 16384))<br>
bitAnd: 16r0FFFFFFF<br>
<br>
and when written as a primitive is<br>
hashMultiply<br>
| low |<br>
low := self bitAnd: 16383.<br>
^(16r260D * low + (16r260D * (self bitShift: -14) + (16r0065 * low) *<br>
16384))<br>
bitAnd: 16r0FFFFFFF<br>
because we don't care about the multiply by 16384 overflowing; when<br>
written as a primitive it won't overflow into a LargePositiveInteger.<br>
</blockquote>
<br>
Hopefully this doesn't mean the primitive got implemented by actually<br>
doing these operations verbatim.  As you have probably seen, that<br>
convoluted arithmetic is done this way in Smalltalk only to simulate a<br>
32x32 multiplication bit-anded down to 28 bits without overflowing<br>
into large integers (the original code from August 2000 had my initials).<br>
<br>
At a sufficiently low level such as C, all that complexity is just an<br>
unsigned multiplication by 1664525.  The image code should still have<br>
a comment to that effect, did it get lost?<br>
<br>
Andres.<br>
<br>
</blockquote>
<br>
</blockquote>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>