[Development] Should QVariant be doing fuzzy comparisons on doubles?
Thiago Macieira
thiago.macieira at intel.com
Mon Sep 19 20:10:51 CEST 2016
On segunda-feira, 19 de setembro de 2016 19:47:12 PDT André Pönitz wrote:
> On Mon, Sep 19, 2016 at 09:20:48AM -0700, Thiago Macieira wrote:
> > This code was there in Qt 5.0, so I kept it when I refactored the numeric
> > comparisons. Now, dealing with QTBUG-56073, I'm wondering if it should be
> > there in the first place.
> >
> > Should we do fuzzy comparisns in QVariant?
>
> No.
Ok, thanks for your and Marc's opinion. I agree with you.
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.
> QVariant should not expose any numeric or conversion functionality and
> *only* be used to store and retrieve data. Comparison/Ordering should
> only be used and only be available to the degree needed to fullfil basic
> container requirements. Everything else has bitten in the past, and
> will necessarily continue to do so, and adding more conceptually *wrong*
> features only digs deeper holes.
That I can't do. The following will still compare equally:
QVariant(1) == QVariant(1.)
And the following will sort:
QVariant::fromValue(0.5f) < QVariant(1) < QVariant(1.5) < QVariant(2ULL)
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list