Meaning of Float>>closeTo:

brad fowlow fowlow at pacbell.net
Sat Mar 3 22:15:38 UTC 2007


I'd say that depends on what you're using it for,
on the precision and context of expected values.

1.1 is very close to 1 for some situations
(if you expect the range of the value to be (-infinity, infinity),
or if you're working with very rough numbers of only a digit's worth  
of precision,
then 1.1 is very close to 1)

1000.1 is not really very close to 1000 in others
(if you're working to full precision, 0.0001 is a pretty big epsilon.)

Float  'closeTo:' meaning within 1/1000th of,
seems to me like being a bit too casual about putting
a fairly specialized test  that someone found useful once or twice
into the general platform as if it were a general utility.

Imagine it were more horribly, but accurately, named
	x withinOneTenthOfOnePercentOf: y,

clearly that's going to be useful sometimes, but it hasn't
the false aura of general utility that comes with the -name- 'closeTo:'

I don't think the long-named version would be taken as a
sensible candidate for inclusion in the platform,
and not just because of the name...

-brad


> On Mar 2, 2007, at 15:57 , Damien Cassou wrote:
>
>> 2007/3/2, Jon Hylands <jon at huv.com>:
>>> Whether it *should* work this way is another question, but it  
>>> certainly
>>> seems consistent...
>>
>> Sure, the result is consistent with the implementation :-) But do we
>> really want that meaning ?
>
> It's a very sensible definition of "close to":
>
> {
> 1.1 closeTo: 1.0.
> 10.1 closeTo: 10.0.
> 100.1 closeTo: 100.0.
> 1000.1 closeTo: 1000.0.
> }
>
> #(false false false true)
>
> - Bert -
>
>
>




More information about the Squeak-dev mailing list