
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
An precision calculation for JavaScript and Node.js. supports numbers, decimals, strings, arrays, matrices and expression. 解决 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 -S
or
yarn add accurate
Supports numbers, decimals, strings, arrays and multidimensional array.
Contains arithmetic expression parser.
Runs on any JavaScript engine.
Is easily extensible.
Open source.
支持数字、小数、字符串、数组和多维数组。
包含算术表达式解析器。
运行在任何 JavaScript 引擎。
易于扩展。
开源的。
import accurate, {
add, addition, subtract, subtraction, multiply, mul, multiplication, division, divide, modulo, modulus, expr
} from 'accurate'
or
const accurate, {
add, addition, subtract, subtraction, multiply, mul, multiplication, division, divide, modulo, modulus, expr
} = require('accurate')
. add(加法)
>
1.1 + 0.3 + 0.1
accurate.add(1.1, 0.3, 0.1)
addition(1.1, 0.3, 0.1)
<-
1.5000000000000002
1.5
1.5
. subtract(减法)
>
1.1 - 0.2 - 0.1
accurate.subtract([1.1, 0.2, 0.1])
subtraction([1.1, 0.2, 0.1])
<-
0.8000000000000002
0.8
0.8
. multiply(乘法)
>
1.1 * 0.1 * 0.2
accurate.multiply([1.1, [0.1, 0.2]])
accurate.mul([1.1, [0.1, 0.2]])
multiplication([1.1, [0.1, 0.2]])
<-
0.022000000000000006
0.022
0.022
0.022
. division(除法)
>
1.1 / 10 / 2
accurate.division([1.1, 10], 2)
accurate.divide([1.1, 10], 2)
<-
0.05500000000000001
0.055
0.055
. modulo(取模)
>
1.1 % 1
accurate.modulo(1.1, 1)
accurate.modulus(1.1, 1)
<-
0.10000000000000009
0.1
0.1
. expr(表达式)
const a = 0.3
const b = 0.1
>
0.3 - 0.1
accurate.expr(`${a}-${b}`)
<-
0.19999999999999998
0.2
>
((1.1+0.3)*4+2*3)/(1.1%0.3-1*0.1)-1*5
accurate.expr('((1.1+0.3)*4+2*3)/(1.1%0.3-1*0.1)-1*5')
accurate.expr('((1.1 + 0.3) * 4 + 2 * 3) / (1.1 % 0.3 - 1 * 0.1) - 1 * 5')
<-
110.99999999999987
111
111
FAQs
An precision calculation for JavaScript and Node.js. supports numbers, decimals, strings, arrays, matrices and expression. 解决 JavaScript 与 Node.js 精度计算(小数、浮点数计算精度)问题。支持数字、小数、字符串、数组、矩阵和表达式。
The npm package accurate receives a total of 107 weekly downloads. As such, accurate popularity was classified as not popular.
We found that accurate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.