code: def bin_for_range( start, end, offsets=None ):
      
      if offsets is None:
          offsets = BIN_OFFSETS
      start_bin, end_bin = start, max(start, end - 1)
      start_bin >>= BIN_FIRST_SHIFT
      end_bin >>= BIN_FIRST_SHIFT
      for offset in offsets:
          if start_bin == end_bin:
              return offset + start_bin
          else:
              start_bin >>= BIN_NEXT_SHIFT
              end_bin >>= BIN_NEXT_SHIFT
      raise Exceptionn("Interval (%d,%d) out of range")
docs: Find the smallest bin that can contain interval (start,end)