code: def continuous_binary_search(f, lo, hi, gap=1e-4):
      
      while hi - lo > gap:
          # in other languages you can force floating division by using 2.0
          mid = (lo + hi) / 2.
          if f(mid):
              hi = mid
          else:
              lo = mid
      return lo
docs: 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))`