Skip to content

Commit

Permalink
Support 'x' for multiplication, normalize operator display in result …
Browse files Browse the repository at this point in the history
…to Unicode
  • Loading branch information
Neamar committed Jun 24, 2018
1 parent 1c13695 commit 0f43e75
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CalculatorProvider implements IProvider {
private Pattern p;

public CalculatorProvider() {
p = Pattern.compile("([0-9.]+)\\s?([+\\-*/×÷])\\s?([0-9.]+)");
p = Pattern.compile("([0-9.]+)\\s?([+\\-*/×x÷])\\s?([0-9.]+)");
}

@Override
Expand Down Expand Up @@ -40,11 +40,14 @@ public void requestResults(String query, Searcher searcher) {
break;
case "*":
case "×":
case "x":
floatResult = lhs * rhs;
operator = "×";
break;
case "/":
case "÷":
floatResult = lhs / rhs;
operator = "÷";
break;
default:
floatResult = Float.POSITIVE_INFINITY;
Expand Down

0 comments on commit 0f43e75

Please sign in to comment.