elementary / calculator

Calculator app designed for elementary OS
https://elementary.io
GNU General Public License v3.0
80 stars 30 forks source link

Error in percentage calculation #222

Open EnriquePG-Noc opened 2 years ago

EnriquePG-Noc commented 2 years ago

What Happened?

When performing an addition or subtraction operation with percentages, the program ignores that it is a percentage. For example: 100 + 2% = 100.02 (the correct would be 102). 100 - 2% = 99.98 (correct would be 98)

This happens with any number you type.

Steps to Reproduce

1) I opened the calculator from "Applications". 2) I typed the numbers from the keyboard, including the symbols. 3) I get the wrong result. 4) I enter the values and symbols from the calculator program itself. 5) I persist with the error.

Expected Behavior

Basically because it is expected to operate with percentages, but what it seems to perform is a decimal operation.

OS Version

6.x (Odin)

Software Version

Latest release (I have run all updates)

Log Output

No response

Hardware Info

No response

jeremypw commented 2 years ago

There was a PR (#137) suggesting a way of dealing with this but it did not get any traction at the time.

Dragonfir3 commented 1 year ago

Without this function it's completely useless for me, Elementary you can remove it from the OS, I have to use another one.

jeremypw commented 1 year ago

Duplicate of #44. This is an old issue for which no universally acceptable solution was found due to the ambiguity of the % operator (which the project leaders would prefer to be ignored altogether).

jeremypw commented 1 year ago

Looked at how Google handles this - essentially it does not interpret % as the mod operator. If you enter a % b then it interpolates x to give a% x b. If you enter a + b + c% it gives a + c% x b. It should be possible to emulate this behaviour. Calculator does not seem to implement mod anyway.

Correction, Calculator recognises mod as the modulo operator (but not %%)

jeremypw commented 11 months ago

@EnriquePG-Noc, @Dragonfir3 I have pushed a PR to address this - #268. If you are able to build and test this I would welcome your comments.