Skip to content

Commit

Permalink
cal express bugfix #367
Browse files Browse the repository at this point in the history
  • Loading branch information
myliang committed Sep 13, 2020
1 parent c2d97d9 commit cbbfdc3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const infixExprToSuffixExpr = (src) => {
operatorStack.push(subStrs.join(''));
} else {
// priority: */ > +-
// console.log(operatorStack, c, stack);
// console.log('xxxx:', operatorStack, c, stack);
if (operatorStack.length > 0 && (c === '+' || c === '-')) {
let top = operatorStack[operatorStack.length - 1];
if (top !== '(') stack.push(operatorStack.pop());
Expand All @@ -99,6 +99,9 @@ const infixExprToSuffixExpr = (src) => {
else break;
}
}
} else if (operatorStack.length > 0) {
const top = operatorStack[operatorStack.length - 1];
if (top === '*' || top === '/') stack.push(operatorStack.pop());
}
operatorStack.push(c);
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export function numberCalc(type, a1, a2) {
ret = num1 * num2;
} else if (type === '/') {
ret = num1 / num2;
if (digits(ret) > 5) return ret.toFixed(2);
return ret;
}
return ret.toFixed(Math.max(al1, al2));
}
Expand Down

0 comments on commit cbbfdc3

Please sign in to comment.