<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr"><br></div><blockquote type="cite"><div dir="ltr"><b>From:</b> Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>><br><b>Date:</b> October 29, 2018 at 11:53:37 AM PDT<br><b>To:</b> The general-purpose Squeak developers list <<a href="mailto:squeak-dev@lists.squeakfoundation.org">squeak-dev@lists.squeakfoundation.org</a>><br><b>Subject:</b> <b>Re: [squeak-dev] What should Integer>>digitCompare: return?</b><br><br></div></blockquote><blockquote type="cite"><div dir="ltr"><span></span><br><span></span><br><blockquote type="cite"><span>On Oct 29, 2018, at 11:46 AM, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Hi Chris,</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>On Oct 28, 2018, at 3:41 PM, Chris Cunningham <<a href="mailto:cunningham.cb@gmail.com">cunningham.cb@gmail.com</a>> wrote:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Looking at LargeIntegers (I'm 64 bit, so these are big):</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>{</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>1152921504606846977 digitCompare:  -1152921504606846977.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>1152921504606846977 digitCompare:  -1152921504606846978.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>1152921504606846978 digitCompare:  -1152921504606846977.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>}  "#(0 -1 1)"</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>{</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>1249 digitCompare: -1249.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>1249 digitCompare: -1250.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>1250 digitCompare: -1249.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>} #(1 1 1)</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>this is correct.  The primitive is supposed to answer -1, 0 or 1 depending on whether the (receiver digitAt: n) is <, =, or > the (argument digitAt: n) where n is either the first digit at which the receiver and argument differ or the last digit.  Since digitAt: does not answer the 2’s complement bit-anded SmallIntegers are not actually inconsistent</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>-1 digitAt: 1 => 1</span><br></blockquote><blockquote type="cite"><span>-1 digitAt: 2 => 0</span><br></blockquote><blockquote type="cite"><span>1 digitAt: 1 => 1</span><br></blockquote><blockquote type="cite"><span>1 digitAt: 2 => 0</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>SmallInteger minVal - 1 digitAt: Smalltalk wordSize => 16 (64-bits) 64 (32-bits)</span><br></blockquote><blockquote type="cite"><span>SmallInteger maxVal + 1 digitAt: Smalltalk wordSize => 16 (64-bits) 64 (32-bits)</span><br></blockquote><span></span><br><span>or more clearly:</span><br><span></span><br><span>(SmallInteger minVal digitCompare: SmallInteger maxVal + 1) = 0</span><br><span></span><br><span>As the comment says, digitCompare: compares the magnitudes, not the 2’s complement representations.</span><br><span></span><br><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>So the method needs a) a really good comment and b) a warning that this is private to the Integer hierarchy implementation and not for general use.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>It looks to me like the use in DateAndTime is a hack that works because LastClockValue is always +ve.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>_,,,^..^,,,_ (phone)</span><br></blockquote></div></blockquote></body></html>