JSPM

robust-split

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3464
  • Score
    100M100P100Q120559F
  • License MIT

convert a number into a 2-part non-overlapping sequence

Package Exports

  • robust-split

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (robust-split) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

robust-split

Use this package when you want to split a double precision floating point number into a 2-part non-overlapping sequence.

Why would you ever want to do that? Well these sequences are an efficient way to perform exact mathmatical operations on numbers in javascript.

install

npm install robust-split

If you want to use this in the browser, check out browserify

use

var rsplit = require('robust-split');

var p = rsplit(0.3);

console.log(p); //[ 2.980232227667301e-9,
                //  0.29999999701976776 ]

You could then pass the sequence into [robust-estimate-float](https://github.com/tmpvar/robust-estimate-float)

var num = require('robust-estimate-float');

var r = num(p);

console.log(r) // 0.3

See the rest of the robust family of packages

credits

This code is pulled from Mikola Lysenko's Robust arithmetic in JavaScript class notes.