[Development] Comparing two reals in Qt code

Dominik Holland dominik.holland at pelagicore.com
Thu Nov 29 15:01:05 CET 2012


Hi all,

last month i had some performance problems on a QML animation running on 
low end hardware (imx233).
I debugged that problem and it was caused because of rounding errors 
during the comparison of two reals.

I fixed that problem by replacing the comparison by a qFuzzyCompare() in 
the Qt4 declarative source code.
Afterwards i checked whether qt5 has the same problem... and it has 
exactly the same problem.

Now i pushed my patch to gerrit 
(https://codereview.qt-project.org/#change,40655) and looked again at 
the code
for any other occurrences.

What i found is, that this happens in many places and it would be a 
really huge effort to change the code to compare the qreals in the right 
way.

Is this already a known problem and do you think that it is worth to try 
to fix the code ?

Best Regards
  Dominik



More information about the Development mailing list