[Development] Implementation of qFuzzyCompare and zero values

Saether Jan-Arve Jan-Arve.Saether at digia.com
Fri Jul 26 12:26:09 CEST 2013

> -----Original Message-----
> From: development-bounces+jan-arve.saether=digia.com at qt-project.org
> [mailto:development-bounces+jan-arve.saether=digia.com at qt-project.org]
> On Behalf Of Thiago Macieira
> Sent: 25. juli 2013 17:26
> To: development at qt-project.org
> Subject: Re: [Development] Implementation of qFuzzyCompare and zero 
> values On quinta-feira, 25 de julho de 2013 09:17:36, André Somers 
> wrote:
>> static inline bool qFuzzyComparePossibleNulls(double p1, double p2) {
>>      if (qFuzzyIsNull(p1)) {
>>          return qFuzzyIsNull(p2); } else if (qFuzzyIsNull(p2)) { return
>>          false; } else { return qFuzzyCompare(p1, p2);
>>      }
>> }
> if ((qFuzzyIsNull(p1) && qFuzzyIsNull(p2)) || qFuzzyCompare(p1, p2))
> If p1 is zero, qFuzzyCompare(p1, p2) will return false unless p2 is 
> also zero.
> But, no, I think we need something like what Jan-Arve is suggesting.
There is a JIRA suggestion now: https://bugreports.qt-project.org/browse/QTBUG-32632

However, a problem with the return value is that it's not very intuitive to know
what distance you want to accept as close enough. I guess we can recommend to test
for a value that more or less matches qFuzzyCompare, since it seems to be acceptable
for most people.

Jan Arve

More information about the Development mailing list