@staticmethod
def getBin(bit, nbits=None, shift=0):
    """ from https://stackoverflow.com/questions/699866/python-int-to-binary """
    pure = bin(bit)[2:]
    if not nbits:
        nbits = len(pure)
    lpure = len(pure)
    admited_shift = nbits - lpure
    if admited_shift < 0:
        mje = (
            'the number of bits must be more than the bits representation of the number. {} ({}) cant be represented in {} bits'
            )
        raise ValueError(mje.format(pure, bit, nbits))
    if shift > admited_shift:
        mje = 'cant shift {} places for bit {} ({})'
        raise ValueError(mje.format(shift, pure, bit))
    if shift:
        shifted = bin(int(pure, 2) << shift)[2:]
    else:
        shifted = pure
    return shifted.zfill(nbits)
