<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div>I'm trying to understand the negative case...<br><br></div>We have the magnitude on one side xMag<br></div>We minSmallInteger in two complement on the other side yTC<br></div>We know that the magnitude of minSmallInteger is yMag=bitInvert(yTC)+1<br></div>We know that all bytes of yTC are 0 but the MSB<br></div>Thus all bytes of bitInvert(yTC) are 16rFF<br></div>Thus all bytes of yMag are 0, but the highest which is (MSB(yTC) xOr: 256) + 1.<br><br></div>Thus, assuming same byte length:<br>MSB(xMag) < MSB(yMag) => x is a CSI<br>MSB(xMag) > MSB(yMag) => x is large<br>MSB(xMag) = MSB(yMag) => we must inquire the LSBs of xMag..<br></div>(1 to: len-1) anySatisfy: [:i | (xMag digitAt: i) ~= 0] => x isLarge<br></div>otherwise, x is minSmallInteger<br><br></div>Eliot, I fail to see the bitInvert(MSB(minSmallInteger))+1 in your code...<br></div>Did I miss something?<br><br></div>Nicolas<br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-03-06 0:37 GMT+01:00 Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br><div dir="ltr">Hi Nicolas,<div><br></div><div> I found my misunderstanding. Can you review this version instead?</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 5, 2015 at 11:41 AM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Nicolas,<div><br></div><div> would you mind also reviewing the attached changes? There's a bug in them somewhere, although I think they're close to correct. The ideas here are to</div><div><br></div><div>- avoid calling firstIndexableField: on every call to unsafeByteOf:at: in isNormalized:, normalizePositive: and normalizeNegative:. Do this by cacheing firstIndexableField in a local pointer variable</div><div>- move the bounds check in cDigitOfCSI:at: out to clients that aren't invoking cDigitOfCSI:at: with in-bounds indices</div><div>- avoid the immediate test in digitLengthOf: when it is known that the object is non-immediate. Do so by adding digitLengthOfNonImmediate:.</div><div><br></div><div>Of course this approach can be extended to other LargeIntegers methods, but one step at a time :-/</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 4, 2015 at 2:49 PM, Nicolas Cellier <span dir="ltr"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>></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"><div><div><br>sLen := interpreterProxy minSmallInteger > 16r3FFFFFFF<br><br></div>sounds like a copy/paste error<br></div>I would expect maxSmallInteger here.<br></div>
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>best,<div>Eliot</div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>best,<div>Eliot</div></div>
</div>
<br></blockquote></div><br></div>