From a0d43b59c61ec51b6ef6c5f9d02045611d0788d8 Mon Sep 17 00:00:00 2001 From: wanfeng Date: Wed, 16 Feb 2022 16:32:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E6=97=B6=E7=B2=BE=E5=BA=A6=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/row.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/row.js b/src/core/row.js index dc3243a7..f6f1836a 100644 --- a/src/core/row.js +++ b/src/core/row.js @@ -1,6 +1,13 @@ import helper from './helper'; import { expr2expr } from './alphabet'; +function add(num1, num2) { + const num1Digits = (num1.toString().split('.')[1] || '').length; + const num2Digits = (num2.toString().split('.')[1] || '').length; + const baseNum = Math.pow(10, Math.max(num1Digits, num2Digits)); + return (num1 * baseNum + num2 * baseNum) / baseNum; +} + class Rows { constructor({ len, height }) { this._ = {}; @@ -162,7 +169,7 @@ class Rows { const result = /[\\.\d]+$/.exec(text); // console.log('result:', result); if (result !== null) { - const index = Number(result[0]) + n - 1; + const index =add(result[0],n-1); ncell.text = text.substring(0, result.index) + index; } }