diff options
author | hjk <hjk121@nokiamail.com> | 2013-03-22 13:26:54 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-02 14:10:54 +0200 |
commit | 6361227846f2beb43ef392f31a208f5711da1c2e (patch) | |
tree | 24070d528b47a572b5d6f51e83e2fc3313fd4512 | |
parent | 35a51de5b494dfeefd55eba0a08411d58565a1f9 (diff) |
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 <andy.shaw@digia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/global/qglobal.h | 4 |
1 files changed, 2 insertions, 2 deletions
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))); } /*! |