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

Error in SimpleCalc PercentageKey Method #173

Open
mhstrayer1 opened this issue Dec 23, 2024 · 1 comment
Open

Error in SimpleCalc PercentageKey Method #173

mhstrayer1 opened this issue Dec 23, 2024 · 1 comment

Comments

@mhstrayer1
Copy link

Current behavior

The PercentageKey method is meant to calculate a percentage of number1 and then apply that percentage via either
addition ,subtraction, multiplication, or division. As coded the division operator does not do this.

"÷" => calculator.Number1!.Value / (number2!.Value / 100) * calculator.Number1!.Value

To get the correct behavior an extra set of parentheses is needed

"÷" => calculator.Number1!.Value /( (number2!.Value / 100) * calculator.Number1!.Value)

For example say number1 = 45 and number2 = 10
as coded: 45/.145 = 20250
modified : 45/(.1
45) = 10

For addition, subtraction, and multiplication normal operator precedence produces the expected result.

@mhstrayer1
Copy link
Author

It took my formatting out
as coded: 45 / .1 x 45 = 20250
modified : 45/ ( .1 x 45) = 10

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

No branches or pull requests

1 participant