Constructors
constructor
-
Parameters
-
Default value flag: boolean = true
Methods
divide
- divide(num1: number, num2: number, ...others: number[]): number
-
Parameters
-
num1: number
-
num2: number
-
Rest ...others: number[]
Returns number
minus
- minus(num1: number, num2: number, ...others: number[]): number
-
Parameters
-
num1: number
-
num2: number
-
Rest ...others: number[]
Returns number
plus
- plus(num1: number, num2: number, ...others: number[]): any
-
Parameters
-
num1: number
-
num2: number
-
Rest ...others: number[]
Returns any
times
- times(num1: number, num2: number, ...others: number[]): number
-
Parameters
-
num1: number
-
num2: number
-
Rest ...others: number[]
Returns number
解决浮动运算问题,避免小数点后产生多数值和计算精度损失
const NP = new NumberPrecision(); NP.plus(0.1, 0.2); >> 0.3 NP.times(0.1, 0.2); >> 0.02 NP.minus(0.2, 0.1); >> 0.1 NP.divide(0.2, 0.1); >> 2