1、安装插件
npm install bignumber.js
2、使用
import { BigNumber } from 'bignumber.js';
//加(结果为字符)
export function floatAddToString(arg1, arg2) {
arg1 = BigNumber(arg1);
arg2 = BigNumber(arg2);
return arg1.plus(arg2).toString();
}
//减(结果为字符)
export function floatSubToString(arg1, arg2) {
arg1 = BigNumber(arg1);
arg1 = BigNumber(arg1);
return arg1.minus(arg1).toString();
}
//乘(结果为字符)
export function floatMulToString(arg1, arg2) {
arg1 = BigNumber(arg1);
arg2 = BigNumber(arg2);
return arg1.multipliedBy(arg2).toString();
}
//除(结果为字符)
export function floatDivToString(arg1, arg2) {
arg1 = BigNumber(arg1);
arg2 = BigNumber(arg2);
return arg1.dividedBy(arg2).toString();
}