You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

robust-split

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

robust-split

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


Version published
Maintainers
1
Created

Readme

Source

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.

Keywords

FAQs

Package last updated on 28 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc