def log2(n):
    """
    Computes the number of binary digits used in the representation on n.

    Input:
        n           An integer.

    Output:
        As in the description. For example, 0 -> 0, 000101010101 -> 9.
    """
    log=-1
    while n>0:
        log+=1
        n=n>>1
    return log