Skip to content

解决JavaScript与Node.js精度计算(小数、浮点数计算精度)问题,轻量级、性能较高。An lightweight and High performance precision calculation for JavaScript and Node.js.

License

Notifications You must be signed in to change notification settings

Ipxxiao/accurate-core

Repository files navigation

Accurate-core · NPM version NPM downloads Build Status Coverage Status code style: prettier

  • An lightweight and high performance precision calculation for JavaScript and Node.js.
  • 解决 JavaScript 与 Node.js 精度计算(浮点数计算精度)问题,轻量级、性能较高。

Browsers support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
Opera
Opera
IE8+ Edge+ last 10 versions last 10 versions last 2 versions last 2 versions last 2 versions

Install

npm i accurate-core -S
or
yarn add accurate-core

Features

  • Lightweight.

  • High performance.

  • No dependencies.

  • Runs on any JavaScript engine.

  • Is easily extensible.

  • Open source.

  • 轻量级。

  • 性能较高。

  • 没有依赖。

  • 运行在任何 JavaScript 引擎。

  • 易于扩展。

  • 开源的。

More features

Usage

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

More