npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

accurate

v1.5.8

Published

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

Downloads

54

Readme

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 | Firefox | Chrome | Safari | iOS Safari | Opera | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | IE8+ Edge+ | last 10 versions | last 10 versions | last 2 versions | last 2 versions | last 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