nemomobile/qmlcalc — pull request #7 by tkenakka (2013-05-23 07:11:47+00:00)
Title: Improve calculation accuracy for qmlcalc

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 a) fix presentation issue in .js somehow, b) 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 uses a Q_INVOKABLE instead of signals or properties in order to keep things synchronous because method is called amidst of a .js routine.