[squeak-dev] #closeTo: on small numbers

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Sun Mar 8 10:30:09 UTC 2020

Hi Stephane,
I have unpublished nasty tests showing such kind of weakness of closeTo:

We can use either an absolute precision, or a relative one, but if we try
to handle both in same message, we'll get in trouble at the boundaries.
The scheme that might work for comparing x and y is to use prescribed
precision as boundary like this:

(xy := x abs max: y abs) > precision
        ["use relative precision"
        ^(x-y) abs <= (xy * precision)].
"use absolute precision"
^(x-y) abs <= precision

Le dim. 8 mars 2020 à 11:23, Stéphane Rollandin <lecteur at zogotounga.net> a
écrit :

> >       (self closeTo: 0.0) ifTrue: [^self abs < 0.0001].
> typo: it's
>         (self closeTo: 0.0) ifTrue: [^num abs < 0.0001].
> Stef
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200308/fc5314c5/attachment.html>

More information about the Squeak-dev mailing list