[squeak-dev] What should Integer>>digitCompare: return?

David T. Lewis lewis at mail.msen.com
Sun Oct 28 23:54:46 UTC 2018


On Sun, Oct 28, 2018 at 03:48:58PM -0700, Chris Cunningham wrote:
> (keyboard failure)
> On Sun, Oct 28, 2018 at 3:41 PM Chris Cunningham <cunningham.cb at gmail.com>
> wrote:
> 
> > Looking at LargeIntegers (I'm 64 bit, so these are big):
> > {
> > 1152921504606846977 digitCompare:  -1152921504606846977.
> > 1152921504606846977 digitCompare:  -1152921504606846978.
> > 1152921504606846978 digitCompare:  -1152921504606846977.
> > }  "#(0 -1 1)"
> >
> > {
> > 1249 digitCompare: -1249.
> > 1249 digitCompare: -1250.
> > 1250 digitCompare: -1249
> >
>  }   "#(1 1 1)"
> 
> The method is actively different for SmallIntegers and LargeIntegers.
> 
> I'm not sure how much this matters - besides the fact that it is lying
> around waiting for someone to use it.  For comparisons of integers, the
> callers check to see if one (or more) of the numbers are negative, then
> handles the issues here.

I would say that this is crying out for some unit tests :-)


> 
> It is also currently used in DateAndTime class methods (#nowWithOffset:
> [deprecated] and #now:offset:), which is probably safe because now is
> always after the epoch.  And we hopefully wouldn't use #now:withOffset: for
> pre-epoch times.
> 
> Is this worth fixing?
> 

Definitely, yes.

Dave



More information about the Squeak-dev mailing list