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

precision-big-math

v1.0.5

Published

A library for high-precision mathematical operations with large numbers

Readme

precision-big-math

BigMath is a high-precision mathematical library for handling large numbers (16+ digits) with accurate arithmetic operations including addition, multiplication, division, exponentiation, square roots, and more.

Installation

npm install precision-big-math

Features

  • Arbitrary precision arithmetic operations
  • Handles numbers with 16+ digits without loss of precision
  • Comprehensive mathematical functions (addition, subtraction, multiplication, division)
  • Advanced operations (power, square root, factorial, GCD, LCM)
  • Error handling with descriptive messages
  • No floating-point precision issues

Usage

const { BigMath } = require('precision-big-math');
// or
import { BigMath } from 'precision-big-math';

Basic Operations

// Addition
const sum = BigMath.add('9999999999999999', '1');
console.log(sum); // '10000000000000000'

// Subtraction
const difference = BigMath.subtract('10000000000000000', '1');
console.log(difference); // '9999999999999999'

// Multiplication
const product = BigMath.multiply('9999999999999999', '9999999999999999');
console.log(product); // '99999999999999980000000000000001'

// Division
const quotient = BigMath.divide('9999999999999999', '3', 10);
console.log(quotient); // '3333333333333333.0000000000'

Advanced Operations

// Power
const power = BigMath.pow('2', 100);
console.log(power); // '1267650600228229401496703205376'

// Square Root
const sqrt = BigMath.sqrt('2', 20);
console.log(sqrt); // '1.41421356237309504880'

// Factorial
const factorial = BigMath.factorial(50);
console.log(factorial); // '30414093201713378043612608166064768844377641568960512000000000000'

// Greatest Common Divisor
const gcd = BigMath.gcd('123456789012345678901234', '987654321098765432109');
console.log(gcd); // '3'

// Least Common Multiple
const lcm = BigMath.lcm('12345678901234567890', '98765432109876543210');
console.log(lcm); // '405349064020168389956139452109876543210'

BigMath.configureBigJs(1000);
const sum = BigMath.add('9'.repeat(1000), '9'.repeat(1000)); // add 2 bignumbers
console.log(sum);

Comparison and Utility Functions

// Compare numbers
const comparison = BigMath.compare('9999999999999999', '10000000000000000');
console.log(comparison); // -1 (less than)

// Round to decimal places
const rounded = BigMath.round('3.14159265358979323846', 5);
console.log(rounded); // '3.14159'

// Absolute value
const absolute = BigMath.abs('-9999999999999999');
console.log(absolute); // '9999999999999999'

// Modulo
const remainder = BigMath.mod('9999999999999999', '3');
console.log(remainder); // '0'

API Reference

Basic Operations

  • BigMath.add(a, b) - Adds two numbers
  • BigMath.subtract(a, b) - Subtracts b from a
  • BigMath.multiply(a, b) - Multiplies two numbers
  • BigMath.divide(a, b, decimalPlaces = 20) - Divides a by b with specified precision

Advanced Operations

  • BigMath.pow(base, exponent) - Raises base to the power of exponent
  • BigMath.sqrt(value, decimalPlaces = 20) - Calculates square root with specified precision
  • BigMath.factorial(n) - Calculates factorial of n
  • BigMath.gcd(a, b) - Finds greatest common divisor
  • BigMath.lcm(a, b) - Finds least common multiple

Utility Functions

  • BigMath.compare(a, b) - Compares two numbers (-1, 0, 1)
  • BigMath.round(value, decimalPlaces = 0) - Rounds to specified decimal places
  • BigMath.abs(value) - Returns absolute value
  • BigMath.mod(a, b) - Returns remainder after division

Error Handling

All methods include comprehensive error handling with descriptive error messages:

try {
  BigMath.divide('100', '0');
} catch (error) {
  console.error(error.message); // 'Division error: Division by zero'
}

License

MIT

Made by Michael Ilyash