From cbbfdc3129ec50f9cc33caec358ad226076d66a9 Mon Sep 17 00:00:00 2001 From: myliang Date: Sun, 13 Sep 2020 17:17:09 +0800 Subject: [PATCH] cal express bugfix #367 --- src/core/cell.js | 5 ++++- src/core/helper.js | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/cell.js b/src/core/cell.js index 7dc70830..0c2b577a 100644 --- a/src/core/cell.js +++ b/src/core/cell.js @@ -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()); @@ -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); } diff --git a/src/core/helper.js b/src/core/helper.js index 2aa0816c..dbdc8bb5 100644 --- a/src/core/helper.js +++ b/src/core/helper.js @@ -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)); }