def int_to_digits(n,B=10,bigendian=False):
    """
    Convert the integer n to its digits in base B
    """
    
    n = abs(n)
    D = []
    
    while n != 0:
        n,r = divmod(n,B)
        D.append(r)
    
    if bigendian:
        return tuple(D)
    else:
        return tuple([i for i in reversed(D)])