I'm trying to convert this hex string F1 into a signed integer.
So I should get as result -15
I have this Python function right here which works good, but somehow doesn't work for this string F1
Code:
def get_signed_value(value):
return -(value & 0x8000) | (value & 0x7fff)
If I pass for example FF5F as value, then I get -161 as response which is correct.
But if I pass F1 I get 241 as response which is not the correct value.