From 60dbd80e5a26182b3ed9e2c60bb7212dfd32632b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Somers?= Date: Wed, 28 Sep 2016 10:13:27 +0200 Subject: Document that qFuzzyCompare does not work on NaN or infinity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ƶ Reviewed-by: Martin Smith --- src/corelib/global/qglobal.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib/global/qglobal.cpp') 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 -- cgit v1.2.3