Meaning of Float>>closeTo:

Damien Cassou damien.cassou at gmail.com
Fri Mar 2 13:51:28 UTC 2007


2007/3/2, Bert Freudenberg <bert at freudenbergs.de>:
> On Mar 2, 2007, at 13:56 , Damien Cassou wrote:
> > 2007/3/2, Bert Freudenberg <bert at freudenbergs.de>:
> >> On Mar 2, 2007, at 12:55 , Damien Cassou wrote:
> >> > 999999 closeTo: 999899.00011.             => true
> >> > 999999 closeTo: 999899.0001.               => false
> >> >
> Huh? Should it answer "maybe"? There is a threshold, and you chose
> your numbers right at that threshold.

I think the answer should be the same. Look at the differences:

999999 - 999899.00011.                          => 99.9998899999773
999999 - 999899.0001.                            => 99.9999000000535

It's nearly a hundred in both cases.

999999 closeTo: 999899.00011.            => true (with a difference of
nearly 100)
2 closeTo: 1                                               => false
(with a difference of 1)

So, what is the threshold ?

-- 
Damien Cassou



More information about the Squeak-dev mailing list