Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong percent calculation #44

Closed
egoistonly opened this issue Oct 29, 2017 · 10 comments
Closed

Wrong percent calculation #44

egoistonly opened this issue Oct 29, 2017 · 10 comments

Comments

@egoistonly
Copy link

Elementary calculator on the left, Gnome calculator on the right. Same calculation 80000+8%
screenshot from 2017-10-29 23 29 54

@Thalexander
Copy link
Collaborator

Well depends on your expected outcome, 8% is 0.08 and so 8000.08 would be my expected outcome for that. (All the calculators I have used also match this behaviour.)

@lewisgoddard
Copy link
Member

The UX team has had this discussion before. Some calculators treat + 8% as *1.08, however that is technically incorrect, and can lead to ambiguities in more complex problems.

@egoistonly
Copy link
Author

egoistonly commented Oct 29, 2017

Is there any special school of algebra? 8% of 80000 is uniquely 6400. Not some calculators treat + 8% as *1.08. All of them do that.

You can even google it:
screenshot from 2017-10-30 02 37 52

@lewisgoddard
Copy link
Member

lewisgoddard commented Oct 30, 2017

The problems come when you do something a little more complicated
Google says 2000 + 3000 + 4% = 5120
That's actually calculating 2000 + ( 3000 + 4% )
That should be 2000 + 3000 + 4% = 5200 according to normal arithmetic processes.
Wolfram Alpha (the better calculator of the two) agrees

@egoistonly
Copy link
Author

egoistonly commented Oct 30, 2017

Well Google also can be wrong) But they understand no one want to know what is percent of cosmic 1 in vacuum (every schoolboy knows it actually).

P.S. Gnome calculator do it right. Again
screenshot from 2017-10-30 11 23 55

@lewisgoddard
Copy link
Member

@elementary/ux

@danirabbit
Copy link
Member

This is a duplicate of an old launchpad issue: https://bugs.launchpad.net/pantheon-calculator/+bug/1465680

The conclusion reached last time was that trying to add a percentage is too ambiguous. Using several different calculators you will get different solutions. From the old issue report:

Google
    10 + 5 - 10% = 14.5
    10 - 10% + 5 = 14

Wolfram Alpha
    10 + 5 - 10% = 13.5
    10 - 10% + 5 = 13.5

web2.0calc.com
    10 + 5 - 10% = 13.5
    10 - 10% + 5 = 14

Excel
    =10 + 5 - 10% = 1490% = 14.9
    =10 - 10% + 5 = 1490% = 14.9

Casio Calculator
    10 + 5 - 10% = 14.5
    10 - 10% + 5 = 14

Something we could do is consider it an invalid expression and not try to evaluate. Otherwise, closing as "Won't Fix". If you want to "add 8%" then multiply by 108%. 8% is just shorthand for 8/100.

@quassy
Copy link

quassy commented Jan 18, 2019

Interestingly, Wolfam Alpha now outputs a different result; I have also added Bing:

Bing
    10 + 5 - 10% = 14.5
    10 - 10% + 5 = 14.9

Google
    10 + 5 - 10% = 14.5
    10 - 10% + 5 = 14

Wolfram Alpha
    10 + 5 - 10% = 13.5
    10 - 10% + 5 = 14

web2.0calc.com
    10 + 5 - 10% = 13.5
    10 - 10% + 5 = 14

Excel / LibreOffice Calc
    =10 + 5 - 10% = 1490% = 14.9
    =10 - 10% + 5 = 1490% = 14.9

LibreOffice Calc
    =5%% = 0.05% = 0.0005

Casio Calculator
    10 + 5 - 10% = 14.5
    10 - 10% + 5 = 14

I'm quite surprised there are no definite mathematical rules and there does not seem to be consensus how these should be treated. In my opinion though, Excel is the only app doing it correctly, as "8% is just shorthand for 8/100" or "In mathematics, a percentage is a number or ratio expressed as a fraction of 100. [...] A percentage is a dimensionless number (pure number)." (English Wikipedia) or (German Wikipedia), ergo: "x %" should just be interpreted as "x / 100".

@cassidyjames
Copy link
Contributor

I'll chime in with what I think a human would do (and what it appears Casio is doing): consider the percentage affecting the immediately previous number/calculation. But I also agree it's ambiguous, and treating it as 10% = 0.10 is also reasonable for a calculator.

@quassy
Copy link

quassy commented Jun 4, 2020

For future reference I just want to add that the great Speedcrunch project (which defaults to keyboard-only input) decided to ditch the % operator alltogether, see this discussion on the issue which I think is quite exhaustive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants