Hello all,
I’m using qFuzzyCompare(a, b) in order to handle all floating point
comparisons, but it has severe limitations when a or b may be zero.
Somewhere in the docs it is recommended to add +1 to the values, but this
is not a really useful suggestion because some of the values might be -1.0,
resulting in 0.0 after the addition.
So in each file which needs to perform floating point comparisons, I always
end up using this or something similar to this macro:
#include <QtGlobal> // qMax, qMin, qFuzzyCompare
#define qFuzzyCompare(a, b) (qFuzzyIsNull(a) && qFuzzyIsNull(b)) ||
qFuzzyCompare((a), (b))
But instead of ad-hoc workarounds, IMHO this caveat should be fixed
straight in the implementation of the qFuzzyCompare() function. A really
old bug report already exists: QTBUG-16819 [bugreports.qt-project.org] it
is open but it seems that discussion ended on 2011 for some reason.
Could anyone add a bit more on this subject?
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development