[Development] Implementation of qFuzzyCompare and zero values
André Somers
andre at familiesomers.nl
Thu Jul 25 09:17:36 CEST 2013
Op 25-7-2013 9:01, Thiago Macieira schreef:
> On quinta-feira, 25 de julho de 2013 07:34:19, André Somers wrote:
>> Would it be an option to _add_ a qFuzzyCompareMightBeNull or something
>> like that then for cases like Juan describes where you don't know if one
>> of the two values might be zero or not? There is no reason to change the
>> behaviour of the current function (as said in the bug report: it may
>> break or slow down other peoples code doing that), but that does not
>> hold adding a new function *defined* to do this, right?
> So, we should add qFuzzyIsNullOrCompare for people who won't do qFuzzyIsNull
> || qFuzzyCompare?
No, for those who think it is a hassle to write [1]
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);
}
}
or some inline equivalent of that everywhere they just want to compare
two doubles they don't know the values of and that might thus be 0. Note
that either of the two doubles may be 0, not just the first as you seem
to imply.
André
[1] taken from http://paste.kde.org/4511/ referenced in the bugreport
mentioned earlier
--
You like Qt?
I am looking for collegues to join me at i-Optics!
More information about the Development
mailing list