- An lightweight and high performance precision calculation for JavaScript and Node.js.
- 解决 JavaScript 与 Node.js 精度计算(浮点数计算精度)问题,轻量级、性能较高。
IE / Edge |
Firefox |
Chrome |
Safari |
iOS Safari |
Opera |
---|---|---|---|---|---|
IE8+ Edge+ | last 10 versions | last 10 versions | last 2 versions | last 2 versions | last 2 versions |
npm i accurate-core -S
or
yarn add accurate-core
-
Lightweight.
-
High performance.
-
No dependencies.
-
Runs on any JavaScript engine.
-
Is easily extensible.
-
Open source.
-
轻量级。
-
性能较高。
-
没有依赖。
-
运行在任何 JavaScript 引擎。
-
易于扩展。
-
开源的。
import accurateCalc, {
add, addition, subtract, subtraction, multiply, mul, multiplication, division, divide, modulo, modulus
} from 'accurate-core'
or
const accurateCalc, {
add, addition, subtract, subtraction, multiply, mul, multiplication, division, divide, modulo, modulus
} = require('accurate-core')
. add(加法)
>
1.1 + 0.3
accurateCalc.add(1.1, 0.3)
addition(1.1, 0.3)
<-
1.4000000000000001
1.4
1.4
. subtract(减法)
>
1.1 - 0.2
accurateCalc.subtract(1.1, 0.2)
subtraction(1.1, 0.2)
<-
0.9000000000000001
0.9
0.9
. multiply(乘法)
>
1.1 * 0.1
accurateCalc.multiply(1.1, 0.1)
accurateCalc.mul(1.1, 0.1)
multiplication(1.1, 0.1)
<-
0.11000000000000001
0.11
0.11
0.11
. division(除法)
>
1.1 / 10
accurateCalc.division(1.1, 10)
accurateCalc.divide(1.1, 10)
<-
0.11000000000000001
0.11
0.11
. modulo(取模)
>
1.1 % 1
accurateCalc.modulo(1.1, 1)
accurateCalc.modulus(1.1, 1)
<-
0.10000000000000009
0.1
0.1