Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including bisect with all npm packages installed. Try it out:

var bisect = require("bisect")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

bisect v1.0.0

Floating point binary search

bisect

Floating point bisection method for JavaScript

Usage

Install using npm:

npm install bisect

And use as follows:

var bisect = require("bisect")

//Find cube root of 5 to 8 decimal places
console.log(bisect(
  function(x) {
    return x * x * x - 5 > 0
  },
  -10, 10, 1e-8))

require("bisect")(predicate, lo, hi[, tolerance])

Supposing that predicate is monotone over the interval [lo,hi), finds the first occurence of where predicate is true up to a resolution of tolerance.

Credits

(c) 2013 Mikola Lysenko. MIT License

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free