[BUG] Inconsistent float soustraction
Paolo Bonzini
bonzini at gnu.org
Sun Feb 17 19:01:46 UTC 2008
> aNumber isNumber ifFalse: [^ false].
> ^ (aNumber asFloat - self) abs < 1.0e-9
>
> I would prefer having = working as I expect, even if it would be wrong
> for smaller values than 1.0e-9. For strict egality, == can be used.
No, you're just supposed to know it when you use floating-point math.
And even if you wanted to do it, you would probably look at relative
error rather than absolute error (i.e. (aNumber asFloat - self) abs /
(self abs min: aNumber asFloat abs) or something like that.
Paolo
More information about the Squeak-dev
mailing list
|