Bisection helper for Javascript