PDA

View Full Version : QPointF equality operator



jenova_project
20th September 2008, 05:15
Hi everyone,

The QPointF equality function seems to take floating point inaccuracy into account, however I have been unable to find any documentation on how it does so (ie. what epsilon value / percentage error etc. is used). Can anyone tell me how it is done and what tolerance values are used?

jpn
22nd September 2008, 16:42
src/corelib/global/qglobal.h:


static inline bool qFuzzyCompare(double p1, double p2)
{
return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2)));
}

static inline bool qFuzzyCompare(float p1, float p2)
{
return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
}