New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

accurate

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

accurate

An precision calculation for JavaScript and Node.js. supports numbers, decimals, strings, arrays, matrices and expression. 解决 JavaScript 与 Node.js 精度计算(小数、浮点数计算精度)问题。支持数字、小数、字符串、数组、矩阵和表达式。

latest
Source
npmnpm
Version
1.5.8
Version published
Weekly downloads
108
350%
Maintainers
2
Weekly downloads
 
Created
Source

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

  • Accurate is an precision calculation for JavaScript and Nodejs. supports numbers, decimals, strings, arrays, multidimensional array and expression.
  • 解决 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 versionslast 10 versionslast 2 versionslast 2 versionslast 2 versions

Install

npm i accurate -S
or
yarn add accurate

Features

  • Supports numbers, decimals, strings, arrays and multidimensional array.

  • Contains arithmetic expression parser.

  • Runs on any JavaScript engine.

  • Is easily extensible.

  • Open source.

  • 支持数字、小数、字符串、数组和多维数组。

  • 包含算术表达式解析器。

  • 运行在任何 JavaScript 引擎。

  • 易于扩展。

  • 开源的。

Usage

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

More

Keywords

accurate

FAQs

Package last updated on 23 Feb 2022

Did you know?

Socket

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.

Install

Related posts