def hex_to_signed_dec(value):
bin_str = f"{bin(int(value, 16))[2:]}"
if bin_str[0] == "1":
return -(int('1' * len(bin_str), 2) - int(value, 16) + 1)
else:
return int(value, 16)
python-16进制转10进制-有符号
最新推荐文章于 2024-04-11 14:07:32 发布