def int2bit(x, w=20):
    """
    Generates a binary representation of an integer number (as a tuple)
    
    >>> bits = int2bit(10, w=4)
    >>> bits
    (1, 0, 1, 0)
    >>> bit2int( bits )
    10
    """
    bits = [ ]
    while x:
        bits.append(x%2)
        x /= 2
    
    # a bit of padding
    bits = bits + [ 0 ] * w
    bits = bits[:w]
    bits.reverse()
    return tuple(bits)