Calculator do rounding unconventionally

REPRODUCIBILITY: Always
OS VERSION: 4.4.0.72
HARDWARE: Sony X Compact
UI LANGUAGE: German
REGRESSION: Not tested

DESCRIPTION:

Divide 15 by 16 with Calculator and wonder why the result will be rounded for unknown reason.
Maybe this is a Feature and not a bug, but i was wodering why there will be rounded on such less Digits.

PRECONDITIONS:

Nothing

STEPS TO REPRODUCE:

  1. Open Calculator and Divide 15 by 16
  2. Result 0,938 is shown but should be 0,9375

EXPECTED RESULT:

Correct Calculated Value

ACTUAL RESULT:

The Second Position after the Komma is being rounded

MODIFICATIONS:

  • Chum
  • Storeman
  • G7 Patch

ADDITIONAL INFORMATION:

Quanto Fa, RPNCalc, MeeCalc and emu48 (Android HP48 emulator) all show 0,9375.

0,938 is correctly rounded to 3 digits after the comma.

Are there any settings in stock calculator regarding the number of digits after the comma? (I can’t check because I did deinstall stock calculator on my phone)

Calculator has no settings of any kind as far as I can tell.

I don’t see anything particularly wrong with the result.

You have to round at some point, and for most basic calculations (which are the use case for this app), three digits are okay-ish.

But the underlying calculation library does support other result properties.

You can try them out by editing /usr/share/jolla-calculator/pages/CalculationsListView.qml, and going to line 129:

127                     ResultItem {
128                         anchors.verticalCenter: parent.verticalCenter
129                         text: calculation.result.valueText
130                         linkText: calculation.result.linkText
131                         coverMode: calculationsListView.coverMode

You may change calculation.result.valueText into either calculation.result.value, or calculation.result.preciseValueText and compare the result.

Hint: when testing, 15/16 isn’t a very good test as its result has four digits after the comma. Try 1/3 or something to see real differences in display.

And by the way: At least the Jolla Calculator does maths correctly, unlike the Windows 10 calculator which doesn’t even get the basic operator precedence (“BODMAS”) right.

2 Likes

It is the third value that is being rounded upwards.

Same happens when i divide 2 / 3 = 0,667
This should be: 0,6 :infinity: (but who has the screen space for that :upside_down_face: )

this can be amended by writing more numbers behind the comma and hide the last digit that is being rounded upwards say 5 or 7-8

The calculator rounds everything to 3 decimals, it seems.

I just was surprised why the Jolla-Calculator did this rounding and others not while my child did homework and write/calculate that division on paper.

2 Likes

It should be something you can set. If you do financial calculations like exchange rate, 3 decimal points can be a very expensive rounding error. Obviously, that depends on the sums, but take a crack at converting 150000 CAD to EUR and see what a difference that rounding error brings.

This is a bug that could simply be solved with a setting.

2 Likes

As this turned out not to be a bug, can we close this? If you want, you can open a feature request.

Ah but the actual calculations are done (I presume) at higher precision. Hence the valueText vs. value properties, and the fact that preciseValueText can have very long strings.

1 Like

But isn’t the point of doing divisions homework like this to learn the method? Using a calculator is cheating, so it’s a good thing in this case that it makes it easier for the teacher to pick out the cheaters :smiling_imp:

Not if you like to verify the result fast.

I’m not so sure. Saying ‘works as designed’ bascially forces you to install a third party calculator. Isn’t that bit strange when it’s a simple matter?

Babbage gives me 3.14159265359 which is 5 more than I usually remember. So, ok, I’ll finally add graphing to Babbage and get on with it.

I agree that the concern is valid, but it is a feature request, not a bug report, although a simple one.

I would generally agree with you if it weren’t a calculator. But for the sake of the work you’re doing I’ll support your judgement.

The difference is 0.1 Eurocent at most, isn’t it?

For instance, 150000 / 0.73920499 (a sample exchange rate I found on the internet) is 202920.708097. The Jolla calculator rounds the result (not the operands) to 3 decimals and gives 202920.708.

1 Like

Right you are, was poor example. Last year I was going in the other direction EURO->CAD but the app that was annoying was only displaying 2 significant digits of the exchange rate. Which was thousands of dollars difference. Wasn’t the calculator app. Still, I always want more :slight_smile:

@fingus I created a patch that addresses this exact problem: [Patch] Increase precision of calculator | OpenRepos.net — Community Repository System

5 Likes

Thanks for the Patch!

I have a small correction. With the Patch enabled, the Comma is replaced with period (dot).

Before:
15:16 = 0,938

After:
15:16 = 0.9375

We use the period-sign to mark the thousand columns like:

10000 = 10.000
100000 = 100.000
1000000 = 1.000.000
…etc