Hello, I want to perform 2 complemented conversion from bin hex string.
# First convert the 16 bit number to binary using:
hex_string = "FFFFFFFFFFFFFDBA12"
unsigned_integer = int(hex_string, base=16)
x = bin(unsigned_integer)
# Then in order to take 2โs complement
x = ~x + 1
# Then finally convert the binary number into decimal using
int(x,2)
I'm getting this error,:
TypeError: bad operand type for unary ~: 'str'