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 🙏

© 2025 – Pkg Stats / Ryan Hefner

double.js

v1.1.0

Published

Emulated float128 or double-double arithmetic. A floating point expansion with 31 accurate decimal digits.

Readme

double.js bundlephobia Codecov

Floating point expansion with 31 accurate decimal digits (106 bits), also known as double-double arithmetic or emulated float128. This library can be useful for fast calculation with extended precision. For example in orbital mechanics, computational geometry and numerically unstable algorithms such as performing triangulation, polygon clipping, inverting matrix and finding differentials.

Algorithm

Number stored as unevaluated sum of two javascript float numbers and uses error-free arithmetic algorithms. This brings accuracy and significant increase in performance in comparison to digit-wise approach, because this float arithmetic is implemented in hardware. Note that there are no theoretical limitations to javascript language since ECMAScript uses 64 bit IEEE 754 with round-to-nearest-even after each operation.

Benchmark

You can check quality, performance and correctness of double.js library in your browser.

Usage

Include double.js script to webpage or install npm package. Here some basic examples

// example with ES6 modules, also you can use ES5
import { Double } from 'double.js';

// '0.3' - '0.1' == 0.2
console.log(new Double('0.3').sub(new Double('0.1')).toNumber());

// L = sqrt(a^2 + 10)
let L = a.sqr().add(10).sqrt();

// S(r) = 4/3 * PI * r^3
const S = (r) => new Double('4.1887902047863909846168578443726').mul(r.pown(3));

// f'(x) = (f(x+h) - f(x)) / h;
let dF = (x) => F(x.add(h)).sub(F(x)).div(h);

// |f'(x)| < 1 ? print(x)
if (dF(x).abs().lt(1)) { console.log(x.toExponential()); }

Further API details you can find in wiki page and check it in sandbox. Be careful when initializing a new floats, for example new Double(0.1) is ok for integer numbers, but you should use new Double('0.1') to get correct results for fractional numburs. All double-double arithmetic functions are accurate and tested, say me if you find something strange.

WebAssembly version

To get speed improvement with wasm, you need to write your entire algorithm with it, because Js<->Wasm interop is too heavy. For example I got x3 boost in Chrome, x3.5 in Safari and x7 in Firefox for mandelbrot set algo, but with hardcoded global variables.

WebGL/WebGPU versions

Just copy/paste the code with MIT copyright. (2do: testing)

Special thanks

To Jeffrey Sarnoff for help me with books and algorithms. Sergey Yanovich for fixing issues with toExponential(). To Max Graey for AssemblyScript remarks. To Yaffle for fixing benchmark.

Want more functions?

If you want more functions (trigonometric for example) open an issue.

References

  1. J.-M. Muller, etc. Tight and rigourous error bounds for basic building blocks of double-word arithmetic., 2017. [PDF]
  2. J.-M. Muller, N. Brisebarre, F. deDinechin, etc. Handbook of Floating-Point Arithmetic, Chapter 14, 2010.
  3. Theodorus Dekker. A floating-point technique for extending the available precision, 1971. [Viewer]
  4. David Monniaux The pitfalls of verifying floating-point computations, 2008 [PDF]
  5. Yozo Hida, Xiaoye Li, David Bailey. Library for Double-Double and Quad-Double Arithmetic, 2000. [PDF]
  6. Christoph Lauter Basic building blocks for a triple-double intermediate format, 2006. [PDF]