def continuous_binary_search(f, lo, hi, gap=1e-4):
    """Binary search for a function

    :param f: boolean monotone function with f(hi) = True
    :param int lo:
    :param int hi: with hi >= lo
    :param float gap:
    :returns: first value x in [lo,hi] such that f(x),
             x is computed up to some precision
    :complexity: `O(log((hi-lo)/gap))`
    """
    while lo - hi > gap:
        # in other languages you want to force floating division by using 2.0
        mid = (lo + hi) / 2
        if f(mid):
            hi = mid
        else:
            lo = mid
    return lo
# snip}
dataset/ETHPy150Open jilljenn/tryalgo/tryalgo/binary_search.py/continuous_binary_search/swapped operands of `-`