diff options
| -rw-r--r-- | src/displayapp/screens/Calculator.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/displayapp/screens/Calculator.cpp b/src/displayapp/screens/Calculator.cpp index 979d12b..e1f36f6 100644 --- a/src/displayapp/screens/Calculator.cpp +++ b/src/displayapp/screens/Calculator.cpp @@ -188,9 +188,7 @@ bool Calculator::Eval() { } } - char next = input.top(); - input.pop(); - + char next = input.pop(); switch (next) { case '+': case '-': @@ -206,8 +204,7 @@ bool Calculator::Eval() { // or (the operator at the top of the operator stack has equal precedence and the token is left associative)) || (getPrecedence(operators.top()) == getPrecedence(next) && leftAssociative(next)))) { // need two elements on the output stack to add a binary operator - if (!output.pushOperator(operators.top())) return false; - operators.pop(); + if (!output.pushOperator(operators.pop())) return false; } operators.push(next); expectingNumber = true; @@ -232,8 +229,7 @@ bool Calculator::Eval() { case ')': while (operators.top() != '(') { // need two elements on the output stack to add a binary operator - if (!output.pushOperator(operators.top())) return false; - operators.pop(); + if (!output.pushOperator(operators.pop())) return false; if (operators.empty()) return false; } // discard the left parentheses |
