<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 1, 2014 at 12:21 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><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-01 4:22 GMT+02:00  <span dir="ltr">&lt;<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>&gt;</span>:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Item was changed:<br>
  ----- Method: LargeIntegersPlugin&gt;&gt;cDigitSub:len:with:len:into: (in category &#39;C core&#39;) -----<br>
+ cDigitSub: pByteSmall len: smallLen with: pByteLarge len: largeLen into: pByteRes<br>
+       | z |<br>
- cDigitSub: pByteSmall<br>
-               len: smallLen<br>
-               with: pByteLarge<br>
-               len: largeLen<br>
-               into: pByteRes<br>
-       | z limit |<br>
        &lt;var: #pByteSmall type: &#39;unsigned char * &#39;&gt;<br>
        &lt;var: #pByteLarge type: &#39;unsigned char * &#39;&gt;<br>
        &lt;var: #pByteRes type: &#39;unsigned char * &#39;&gt;<br>
<br>
+       z := 0. &quot;Loop invariant is -1&lt;=z&lt;=1&quot;<br>
+       0 to: smallLen - 1 do:<br>
-       z := 0.<br>
-       &quot;Loop invariant is -1&lt;=z&lt;=1&quot;<br>
-       limit := smallLen - 1.<br>
-       0 to: limit do:<br>
                [:i |<br>
                z := z + (pByteLarge at: i) - (pByteSmall at: i).<br>
+               pByteRes at: i put: z - (z // 256 * 256). &quot;sign-tolerant form of (z bitAnd: 255)&quot;<br></blockquote><div><br></div><div>Frankly, having z declared unsigned int and just doing  pByteRes at: i put: (z bitAnd: 16rFF) as I suggested would be way way simpler and will ALWAYS work.<br>

</div><div>Why the hell invoke the complications of signed arithmetic when the content pByteRes is unsigned???<br></div></div></div></div></blockquote><div><br></div><div>I&#39;m not maintaining the plugin.  But I broke it in fixing the unsigned division anomaly.  I just wanted it to work again as quickly as possibly without expending effort.  I made the minimum changes I could to keep it working.  I&#39;m much happier to have you maintain the plugin.  You have the expertise and experience.</div>
<div><br></div><div>Nicolas, my priority is to have Spur working.  I don&#39;t want to have to expend lots of energy changing plugins to get Spur working.  My submitting this fix is not an endorsement of any kind.  It&#39;s merely expediency.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Even if z is declared signed, (z bitAnd: 255) would work on a vast majority of compiler/processor because most compiler/processor would use a 2-complement representation.<br>
</div><div>But it&#39;s technically implementation-defined.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+               z := z signedBitShift: -8].<br></blockquote><div><br></div><div>i think this one is OK too on a vast majority of machines, but this is as well technically implementation defined.<br></div><div>Some weird compiler/processor pair may as well fill left bits with zeroes, or not even use 2-complement...<br>

<br></div><div>z here is a carry and should contain either 0, or -1 (that is UINT_MAX) after this operation.<br></div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


+       smallLen to: largeLen - 1 do:<br>
-               pByteRes at: i put: z - (z // 256 * 256).<br>
-               &quot;sign-tolerant form of (z bitAnd: 255)&quot;<br>
-               z := z // 256].<br>
-       limit := largeLen - 1.<br>
-       smallLen to: limit do:<br>
                [:i |<br>
                z := z + (pByteLarge at: i) .<br>
+               pByteRes at: i put: z - (z // 256 * 256). &quot;sign-tolerant form of (z bitAnd: 255)&quot;<br>
+               z := z signedBitShift: -8].<br>
-               pByteRes at: i put: z - (z // 256 * 256).<br>
-               &quot;sign-tolerant form of (z bitAnd: 255)&quot;<br>
-               z := z // 256].<br>
  !<br></blockquote></div><br></div><div class="gmail_extra">Isn&#39;t there another funny signed shift in Large Integer division?<br></div><div class="gmail_extra">This would deserve a review too, because division is inlining its own sort of subtraction...<br>

</div></div>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div>
</div></div>