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

Walter Bright newshound2 at digitalmars.com
Wed Oct 20 11:58:06 PDT 2010


Andrei Alexandrescu wrote:
> 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?

I would rather force the user to make a decision about what precision he's 
looking for, rather than a default.


More information about the Digitalmars-d mailing list