[Development] Implementation of qFuzzyCompare and zero values
Juan Navarro
oneorjuan at gmail.com
Fri Jul 26 10:53:19 CEST 2013
On Thu, Jul 25, 2013 at 5:26 PM, Thiago Macieira
<thiago.macieira at intel.com>wrote:
>
> if ((qFuzzyIsNull(p1) && qFuzzyIsNull(p2)) || qFuzzyCompare(p1, p2))
>
>
That's exactly like the macro with which I end up "convering" the current
Qt implementation.
On your first reply, you also said that
On Thu, Jul 25, 2013 at 1:19 AM, Thiago Macieira
<thiago.macieira at intel.com>wrote:
>
> You have to somehow tell qFuzzyCompare about the magnitude of your
> comparison.
> An error of 1000000 is acceptable when your numbers are in the order of
> 1e12.
>
> ...
>
> Can't do and won't do that. qFuzzyCompare is meant for non-zero numbers. We
> don't want to add the overhead of zero comparisons when the numbers in
> question can't be null.
>
>
In my opinion, if a function requires the user to provide a magnitude value
(for whatever reason), then that value should be explicitly given in an
additional parameter, not implicitly given as an added value to the already
given parameters... I think that's a very bad design decision, which finds
it's own limitations very fast with the example I gave in the first mail:
working with magnitudes of 1e12, I cannot just call qFuzzyCompare(a + 1e12,
b + 1e12), because a or b might be -1e12!
On the other hand, explicitly not supporting zero values seems to me like a
rather arbitrary imposition for a function which compares values. There are
so many possible scenarios in which to compare 2 floating-point numbers in
which one or both might be "human zero". Temperatures, speeds, weights,
coordinates, time-travelling, you name it!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130726/39c948d1/attachment.html>
More information about the Development
mailing list