Meaning of Float>>closeTo:

Jon Hylands jon at huv.com
Fri Mar 2 14:18:20 UTC 2007


On Fri, 2 Mar 2007 15:06:03 +0100, "Damien Cassou"
<damien.cassou at gmail.com> wrote:

> Ok, so if two numbers have nearly 100 of difference, #closeTo:
> shouldn't answer true. Right ?

If you look at the routine, it basically says two numbers that are within
0.01% of each other. Large numbers don't have to be as close as small
numbers.

For the first example:

999999.0 closeTo: 999899.00011
999999.0 closeTo: 999899.0001

You've found the exact threshold where it rolls over from being < 0.01% to
> 0.01%.

Whether it *should* work this way is another question, but it certainly
seems consistent...

Later,
Jon

--------------------------------------------------------------
   Jon Hylands      Jon at huv.com      http://www.huv.com/jon

  Project: Micro Raptor (Small Biped Velociraptor Robot)
           http://www.huv.com/blog



More information about the Squeak-dev mailing list