Instead of qFuzzyCompareMightBeNull, why can't we have a function that returns
the number of representable numbers between two floats?
boost has a similar function, math::float_distance(a, b)
Qt style API could then be something like:
unsigned qFloatDistance(float a, float b);
You can then compare two floats like this:
if (qFloatDistance(a,b) < 4) {
// precise enough
}
This could be implemented the same way as explained in the link Samuel gave.
(http://www.cygnus-software.com/papers/comparingfloats/Comparing%20floating%20point%20numbers.htm#_Toc135149455)
Jan Arve
From: [email protected]
[mailto:[email protected]] On
Behalf Of Laszlo Papp
Sent: 25. juli 2013 09:47
To: André Somers
Cc: [email protected]
Subject: Re: [Development] Implementation of qFuzzyCompare and zero values
On Thu, Jul 25, 2013 at 6:34 AM, André Somers
<[email protected]<mailto:[email protected]>> 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?
That was also my thought after reading Thiago's email. It would not bloat the
library after all as it is just a small function. I think the bugreport should
be reopened accordingly, and then fixed unless there are good reasons against
it.
Laszlo
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development