def dec2bin(dec_num, bit_wide=20):
_, bin_num_abs = bin(dec_num).split('b')
if len(bin_num_abs) > bit_wide:
raise ValueError # 数值超出bit_wide长度所能表示的范围
else:
if dec_num >= 0:
bin_num = bin_num_abs.rjust(bit_wide, '0')
else:
_, bin_num = bin(2**bit_wide + dec_num).split('b')
return bin_num
a=dec2bin(-679171,21) #21 是20bit
print(a)
def com2dec(com_str: str): # :str
# convert complete bin string to dec
if(com_str[0