Intervals

Lex Spoon lex at cc.gatech.edu
Tue Nov 30 15:57:35 UTC 1999


Michael Donegan <invader at zilker.net> wrote:
> >Aren't floats fun!  :-)
> >
> 
> No kidding. The introduction of floats causes a problem because there is no
> unified notion of float comparison in Smalltalk. We might decide, e.g. to
> use the closeTo: method to determine whether values were in the interval.
> But, that wouldn't always work as Dave shows. It is clear that at least one
> author assumed that Intervals had integer values only (see the source for
> setFrom:to:by:). The only general solution would be to include the fuzz or
> epsilon value with an instance and defaulting it to some class variable.
> But there are other instances of comparison (like closeTo: and maybe
> others) that would not be helped by this solution.
> 


Comparing floats for equality is usually pointless.  That considered,
why don't we just use exact equality when testing for inclusion, and let
people who want some sort of fuzzy match define their own match.

The only trick is to make sure that includes: uses the same calculations
as do: does; it would be nice for the following to always return all
trues:

	anInterval collect: [ :x | anInterval includes: x ]


Lex





More information about the Squeak-dev mailing list