Skip to content

Error in SimpleCalc PercentageKey Method #173

@mhstrayer1

Description

@mhstrayer1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions