diff options
author | André Somers <andre.somers@kdab.com> | 2016-09-28 10:13:27 +0200 |
---|---|---|
committer | Andre Somers <andre.somers@kdab.com> | 2016-10-26 08:39:46 +0000 |
commit | 60dbd80e5a26182b3ed9e2c60bb7212dfd32632b (patch) | |
tree | 9080a37a6adf5c1add534015c26858d17fcf089f | |
parent | 047e3f8f046ac9267cc27d47a48189ae2cbfe0ef (diff) |
Document that qFuzzyCompare does not work on NaN or infinity
On a discussion in the Development mailing list it became clear that
qFuzzyCompare does not work for NaN or infinity values. That was not
mentioned in the method documentation though. This patch fixes that
hiatus. It also clarifies how to deal with the comparing to 0.0
limitation.
Change-Id: I8b6d54cc0c1136e79b0d7be1a62bc9ed394d2575
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Martin Smith <martin.smith@theqtcompany.com>
-rw-r--r-- | src/corelib/global/qglobal.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 6d7fbce946..59799b07bb 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -4109,8 +4109,10 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) Compares the floating point value \a p1 and \a p2 and returns \c true if they are considered equal, otherwise \c false. - Note that comparing values where either \a p1 or \a p2 is 0.0 will not work. - The solution to this is to compare against values greater than or equal to 1.0. + Note that comparing values where either \a p1 or \a p2 is 0.0 will not work, + nor does comparing values where one of the values is NaN or infinity. + If one of the values is always 0.0, use qFuzzyIsNull instead. If one of the + values is likely to be 0.0, one solution is to add 1.0 to both values. \snippet code/src_corelib_global_qglobal.cpp 46 |