def covered_interval(bin):
    """
    Given a bin number `bin`, return the interval covered by this bin.

    :arg int bin: Bin number.

    :return: Tuple of `start, stop` being the zero-based, open-ended interval
      covered by `bin`.
    :rtype: tuple(int)

    :raise OutOfRangeError: If bin number `bin` exceeds the maximum bin
      number.
    """
    if bin < 0 or bin > MAX_BIN:
        raise OutOfRangeError(
            'Invalid bin number %d (maximum bin number is %d)'
            % (bin, MAX_BIN))

    shift = SHIFT_FIRST
    for offset in BIN_OFFSETS:
        if offset <= bin:
            return bin - offset << shift, bin + 1 - offset << shift
        shift += SHIFT_NEXT
Given a bin number `bin`, return the interval covered by this bin.

    :arg int bin: Bin number.

    :return: Tuple of `start, stop` being the zero-based, open-ended interval
      covered by `bin`.
    :rtype: tuple(int)

    :raise OutOfRangeError: If bin number `bin` exceeds the maximum bin
      number.