[Development] Should QVariant be doing fuzzy comparisons on doubles?
olivier at woboq.com
Tue Sep 20 11:29:32 CEST 2016
On Dienstag, 20. September 2016 03:08:42 CEST Kevin Kofler wrote:
> Thiago Macieira wrote:
> > Since this is a P3 and 5.8 hasn't been released, I will push the behaviour
> > change to 5.8 and drop the fuzzy comparison.
> Is such a behavior change really acceptable for 5.8? I think it can break
> applications that were relying on the current behavior in pretty bad, hard
> to debug ways (random bugs based on rounding errors).
I tend to agree with that.
This is a behavior change, and i see no reason to do it. Comparing double for
equality with operator== is a bad idea.
I know QVariant::operator== has problems, but i don't think this is something
that should be changed.
(Correct me if i'm wrong, but this might actually have quite some bad
performance impact on QML where lot of bindings are done on a real value and
they are compared for equality before emiting the changed signal. (or does QML
takes the value out of qvariant before comparing?))
On the other hand, the fact that qFuzzyCompare(inf, -inf) returns true looks
like a bug within qFuzzyCompare.
Woboq - Qt services and support - https://woboq.com - https://code.woboq.org
More information about the Development