Commit e68f472b authored by Kitten9533's avatar Kitten9533 Committed by 陈帅

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

Fix digitUppercase (2.01) error returned as 贰元整
Signed-off-by: default avatarjiangjiahao <1173860556@qq.com>
parent 95dbbf9f
......@@ -70,14 +70,23 @@ export function getPlainNode(nodeList, parentPath = '') {
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) {
const fraction = ['', ''];
const digit = ['', '', '', '', '', '', '', '', '', ''];
const unit = [['', '', '亿'], ['', '', '', '']];
const unit = [['', '', '亿'],['', '', '', '', '']];
let num = Math.abs(n);
let s = '';
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 || '';
num = Math.floor(num);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment