nemomobile/qmlcalc — pull request #8 by tkenakka (2013-05-24 07:35:06+00:00)
Title: Improve calculation accuracy, fix nemomobile Bug 674. +Logging

Replaced first pull request with this better version :)

Nemomobile bug:
https://bugs.nemomobile.org/show_bug.cgi?id=674

Although javascript Number type should be double, the calculator UI displays incorrect results for calculations like:
"2.01-2", "2.011-2" or "0.123456789 - 0.1"
due to loss of precision in decimals, a common problem which applies to all computing environments.
This change implements a single calculation function on Qt side which is called amidst the js function. Actual fix is the line where result is converted to string using 13 decimals, this seemed to give correct resultsand rounding presentationwise.
If you want to consider other approaches then
- fix presentation issue in .js somehow
- in addition to this fix move whole .js routine to Qt side (which tends to have better performance anyway), if you wish to have logic in one engine.
This approach uses a Q_INVOKABLE instead of signals or properties in order to keep things synchronous because method is called amidst of a .js routine.