You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
457 B

/* 解决js计算精度问题 */
import { Decimal } from 'decimal.js';//引入
class Calc {
add(num1,num2) {
return new Decimal(num1).add(new Decimal(num2))
}
sub(num1,num2) {
return new Decimal(num1).sub(new Decimal(num2))
}
mul(num1,num2) {
return new Decimal(num1).mul(new Decimal(num2))
}
div(num1,num2) {
return new Decimal(num1).div(new Decimal(num2))
}
}
export const calc = new Calc();