提交 e68f472b 编写于 作者: K Kitten9533 提交者: 陈帅

修复digitUppercase(2.01)返回为贰元整的,数字大写增加了“万亿” (#1589)

Fix digitUppercase (2.01) error returned as 贰元整
Signed-off-by: Njiangjiahao <1173860556@qq.com>
上级 95dbbf9f
...@@ -70,14 +70,23 @@ export function getPlainNode(nodeList, parentPath = '') { ...@@ -70,14 +70,23 @@ export function getPlainNode(nodeList, parentPath = '') {
return arr; return arr;
} }
function accMul(arg1, arg2) {
let m = 0;
const s1 = arg1.toString();
const s2 = arg2.toString();
m += s1.split(".").length > 1 ? s1.split(".")[1].length : 0;
m += s2.split(".").length > 1 ? s2.split(".")[1].length : 0;
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / 10 ** m;
}
export function digitUppercase(n) { export function digitUppercase(n) {
const fraction = ['', '']; const fraction = ['', ''];
const digit = ['', '', '', '', '', '', '', '', '', '']; const digit = ['', '', '', '', '', '', '', '', '', ''];
const unit = [['', '', '亿'], ['', '', '', '']]; const unit = [['', '', '亿'],['', '', '', '', '']];
let num = Math.abs(n); let num = Math.abs(n);
let s = ''; let s = '';
fraction.forEach((item, index) => { fraction.forEach((item, index) => {
s += (digit[Math.floor(num * 10 * 10 ** index) % 10] + item).replace(/零./, ''); s += (digit[Math.floor(accMul(num, 10 * 10 ** index)) % 10] + item).replace(/零./, '');
}); });
s = s || ''; s = s || '';
num = Math.floor(num); num = Math.floor(num);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册