def integer_log2_round_up(x):
    """
    Returns the number of bits required to represent `x` distinct values---i.e.
    log2(x) rounded up.
    """
    assert x > 0
    bits = 1
    representable = 2 ** bits
    while representable < x:
        bits += 1
        representable *= 2
    return bits