这是我目前所拥有的:
decimalEquivalent 是表示整数的变量。
#One's complement of the binary string is shown
onesComplement = bin(~decimalEquivalent)
print(f'The negative no (-{decimalEquivalent}) using 1\'s Complement: {onesComplement}')
#Two's complement of the binary string is shown
twosComplement = onesComplement + bin(1)
print(f'The negative no (-{decimalEquivalent}) using 2\'s Complement: {twosComplement}')
你能帮我弄清楚我做错了什么吗?
我试图确定整数的补码和补码。