← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-round-fix into lp:ubuntu-calculator-app

 

Bartosz Kosiorek has proposed merging lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-round-fix into lp:ubuntu-calculator-app.

Commit message:
Enable BigNumber to resolve issues with rounding floating point numbers

Requested reviews:
  Ubuntu Calculator Developers (ubuntu-calculator-dev)
Related bugs:
  Bug #1445152 in Ubuntu Calculator App: "Problem with rounding floats - 12,70...01 instead of 12,7"
  https://bugs.launchpad.net/ubuntu-calculator-app/+bug/1445152

For more details, see:
https://code.launchpad.net/~gang65/ubuntu-calculator-app/ubuntu-calculator-app-round-fix/+merge/256745

Enable BigNumber to resolve issues with rounding floating point numbers
-- 
Your team Ubuntu Calculator Developers is requested to review the proposed merge of lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-round-fix into lp:ubuntu-calculator-app.
=== modified file 'app/ubuntu-calculator-app.qml'
--- app/ubuntu-calculator-app.qml	2015-04-06 12:49:36 +0000
+++ app/ubuntu-calculator-app.qml	2015-04-18 20:25:25 +0000
@@ -102,6 +102,7 @@
     }
 
     function formulaPush(visual) {
+        mathJs.config({number: 'bignumber'});
         // If the user press a number after the press of "=" we start a new
         // formula, otherwise we continue with the old one
         if (!isNaN(visual) && isLastCalculate) {
@@ -160,6 +161,7 @@
     }
 
     function calculate() {
+        mathJs.config({number: 'bignumber'});
         if ((longFormula === '') || (isLastCalculate === true)) {
             errorAnimation.restart();
             return;

=== modified file 'tests/autopilot/ubuntu_calculator_app/tests/test_main.py'
--- tests/autopilot/ubuntu_calculator_app/tests/test_main.py	2015-03-26 21:16:14 +0000
+++ tests/autopilot/ubuntu_calculator_app/tests/test_main.py	2015-04-18 20:25:25 +0000
@@ -289,6 +289,11 @@
         self._assert_result_is(u'−66')
         self._assert_history_contains(u'66i×i=−66')
 
+    def test_floating_point_round_error(self):
+        self.app.main_view.insert('0.1+0.2=')
+        self._assert_result_is(u'0.3')
+        self._assert_history_contains(u'0.1+0.2=0.3')
+
     def _assert_result_is(self, value):
         self.assertThat(self.app.main_view.get_result,
                         Eventually(Equals(value)))


Follow ups