1扒磁、安裝插件
npm install bignumber.js
2、使用
import { BigNumber } from 'bignumber.js';
//加(結(jié)果為字符)
export function floatAddToString(arg1, arg2) {
arg1 = BigNumber(arg1);
arg2 = BigNumber(arg2);
return arg1.plus(arg2).toString();
}
//減(結(jié)果為字符)
export function floatSubToString(arg1, arg2) {
arg1 = BigNumber(arg1);
arg1 = BigNumber(arg1);
return arg1.minus(arg1).toString();
}
//乘(結(jié)果為字符)
export function floatMulToString(arg1, arg2) {
arg1 = BigNumber(arg1);
arg2 = BigNumber(arg2);
return arg1.multipliedBy(arg2).toString();
}
//除(結(jié)果為字符)
export function floatDivToString(arg1, arg2) {
arg1 = BigNumber(arg1);
arg2 = BigNumber(arg2);
return arg1.dividedBy(arg2).toString();
}