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>
This commit is contained in:
André Somers 2016-09-28 10:13:27 +02:00 committed by Andre Somers
parent 047e3f8f04
commit 60dbd80e5a

View File

@ -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