approxEqual() has fooled me for a long time...

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Oct 20 09:49:35 PDT 2010


On 10/20/10 10:52 CDT, Don wrote:
> I don't think it's possible to have a sensible default for absolute
> tolerance, because you never know what scale is important. You can do a
> default for relative tolerance, because floating point numbers work that
> way (eg, you can say they're equal if they differ in only the last 4
> bits, or if half of the mantissa bits are equal).
>
> I would even think that the acceptable relative error is almost always
> known at compile time, but the absolute error may not be.

I wonder if it could work to set either number, if zero, to the smallest 
normalized value. Then proceed with the feqrel algorithm. Would that work?

Andrei


More information about the Digitalmars-d mailing list