From 6361227846f2beb43ef392f31a208f5711da1c2e Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 22 Mar 2013 13:26:54 +0100 Subject: Reduce the likelihood of underflows in qFuzzyCompare As indicated in the discussion of the bug report, this does not address the real problem but only reduces the frequency it occurs. Task-number: QTBUG-26453 Change-Id: I20ac3f41f52effb674bee6924ccdfd2f641576ef Reviewed-by: Andy Shaw Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/global/qglobal.h') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index c45ad12e99..58c4256aa5 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -676,12 +676,12 @@ typedef void (*QFunctionPointer)(); Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) { - return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2))); + return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2))); } Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) { - return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2))); + return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2))); } /*! -- cgit v1.2.3