[squeak-dev] #closeTo: on small numbers
nicolas.cellier.aka.nice at gmail.com
Sun Mar 8 10:30:09 UTC 2020
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
> > (self closeTo: 0.0) ifTrue: [^self abs < 0.0001].
> typo: it's
> (self closeTo: 0.0) ifTrue: [^num abs < 0.0001].
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev