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 🙏

© 2026 – Pkg Stats / Ryan Hefner

bignums

v1.0.1

Published

js高精度运算

Readme

安装

npm install bignums -S

使用

组件内使用
import bignum from 'bignums';

main.js里面使用
import bignum from 'bignums';
Vue.prototype.bignum = bignum;

sum

// 两数之和
var x = bignum.sum('11', 23)
x.toNumber() // 34

// 多个参数
arr = [2, new bignum(14), '15.9999', 12]
var y = bignum.sum(...arr)
y.toString() // '43.9999'

maximum,minimum

// 求最大值,简写 max,min

var x = [2222, 3333, '4444']
bignum.max(...x).toNumber() // 4444
bignum.min(...x).toNumber() // 2222

decimalPlaces(dp)

// 确定小数位数

var x = new bignum(1234.5678912345)
var y = new bignum(1234.56)
x.dp(2).toNumber() // 1234.56
y.dp(10).toNumber() // 1234.56

plus

//加法运算

0.1 + 0.2 // 0.30000000000000004
var x = new bignum(0.1)
x.plus(0.2).toNumber() // 0.3

minus

//减法运算

0.3 - 0.1 // 0.19999999999999998
var x = new bignum(0.3)
x.minus(0.1) // 0.2

multipliedBy(times)

//乘法运算

0.6 * 3 // 1.7999999999999998
var x = new bignum(0.6)
x.times(3) // 1.8

dividedBy(div)

//除法运算

var x = new bignum(300)
x.div(3).toNumber() // 100
x.div(7).dp(3).toNumber() // 42.857

dividedToIntegerBy(idiv)

//除法运算,返回整数

var x = new bignum(5)
x.idiv(3).toNumber() // 1
x.idiv(0.7).toNumber() // 7

modulo(mod)

//取余

1 % 0.9 // 0.09999999999999998
var x = new bignum(1)
x.mod(0.9).toNumber() // 0.1

toFixed

//控制小数位数,不够后面补 0

var x = 3.456
var y = new bignum(x)
x.toFixed().toNumber() // 3
y.toFixed().toNumber() // 3.456
y.toFixed(0).toNumber() // 3
y.toFixed(2).toNumber() // 3.46
y.toFixed(5).toNumber() // 3.45600