sosauce / CuteCalc

CuteCalc is a simple,lightweight and open-source calculator app for Android.
GNU General Public License v3.0
98 stars 8 forks source link

Logic Bug #64

Closed realeatham closed 5 months ago

realeatham commented 6 months ago

Describe the bug Percentage modifier does not work correctly

To Reproduce Do 59 - 9%, it will output 58.91 instead of 53.69

Expected behavior It should subtract 9% of 59 not 9% of 100

Screenshots

https://github.com/sosauce/CuteCalc/assets/136866675/a50c9fcc-ac2f-497c-8564-905e4a24ffd4

Smartphone (please complete the following information):

I think I know what is wrong, I haven't looked at the code yet but it probably says percent is just /100

sosauce commented 6 months ago

yeah its /100

realeatham commented 6 months ago

@notKamui do you know of a way to solve this easily

realeatham commented 6 months ago

I have no clue how I would

notKamui commented 6 months ago

@realeatham

This is not an issue to me.

"59 - 9%" SHOULD be read as "59 minus 9/100" and not "59 minus 9/100 of 59".

Some calculators will interpret this bastard expression as the second sentence, but it's effectively quite rare because it's very much ambiguous and not normative. In "59 - 9%", there is absolutely nothing that explicits that "9%" is refering to "9/100 of 59".

In fact, most basic calculators either do not have the % symbol XOR do not support continuous infix notation. What I mean is that the calculators that support % generally display only the result of each operation individually each time you press on an operator, in which case the % has no ambiguity.

I would just remove the % operator if I where you. It's generally redundant.

notKamui commented 6 months ago

To add to this, Keval will never be able to support this, and most expression evaluators won't either, because it is contextual expression evaluation, which, again, is not conventional at all.

realeatham commented 6 months ago

oh ok

realeatham commented 6 months ago

Then it should be removed no ons don't need a /100 button

notKamui commented 6 months ago

To be clear, I COULD add support for contextual operations, but I'm not quite sure I want this for Keval.

sosauce commented 5 months ago

Should I close this or rename it

realeatham commented 5 months ago

close as not planned