def dec2bin(decimal, bits) -> str:
    """ Converts a decimal number to it's 2nd complement binary representation

    :param decimal: decimal to be converted
    :param bits: number of bits for binary representation
    :return: string containing binary representation of decimal number
    """
    binary = bin(decimal & int("1" * bits, 2))[2:]
    return ("{0:0>%s}" % bits).format(binary)