serso / android-calculatorpp

Android Calculator
430 stars 205 forks source link

88%+12% != 1 #160

Closed VitorVilela7 closed 9 years ago

VitorVilela7 commented 9 years ago

Calculator is set on advanced mode. I don't think it's a rounding issue since it's a quite obvious expression.

Picture: screenshot_2015-06-22-08-01-38

serso commented 9 years ago

In the world of percentages arithmetics isn't that simple. 88%+12% means that you get first 88% of something (1 * 0.88 = 0.88) and then add 12% of it (0.88 + 0.88 * 0.12) which is obviously not the same as 0.88 + 0.12. If you want to sum numbers first and then calculate percentage - just use brackets: (0.88+0.12)%

VitorVilela7 commented 9 years ago

Oh I see. Oh well, I didn't know it was supposed to have such weird behavior, but it makes sense. Thanks for clarifying it.

Please desconsider this then. Em 23/06/2015 03:36, "Sergey Solovyev" notifications@github.com escreveu:

In the world of percentages arithmetics doesn't work that easy. 88%+12% means that you get first 88% of something (1 * 0.88 = 0.88) and then add 12% of it (0.88 + 0.88 * 0.12) which is obviously not the same as 0.88 + 0.12. If you want to sum numbers first and then calculate percentage - just use brackets: (0.88+0.12)%

— Reply to this email directly or view it on GitHub https://github.com/serso/android-calculatorpp/issues/160#issuecomment-114377251 .