def number2binary(v, dynamic_padding=False, padded_length=None):
    """ Convert an integer value to the equivalent string of 1 and 0 characters. """
    s = ""
    while v:
        s = [ "0", "1" ][v & 1] + s
        v >>= 1
    if dynamic_padding:
        w = 4
        while w < len(s):
            w <<= 1
    else:
        w = len(s) if padded_length is None else padded_length
    return "0"*(w-len(s)) + s