Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
4.7.1
-
None
Description
Current implementation of qFuzzyCompare for floats and doubles can fail if p1 or p2 are equal to 0.0. That is documented, but I don't see any reason to do that. Why just not to handle it?
Current implementation:
static inline bool qFuzzyCompare(double p1, double p2) { return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2))); }
Always working implementation:
static inline bool qFuzzyCompare(double p1, double p2) { if( p1 != 0.0 && p2 != 0.0) { return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2))); } else { return (qFuzzyCompare(p1+1.0, p2+1.0)); } }
Standart implementation can result in strange errors, isn't it?