Given a byte in two's complement form, I am attempting to convert that byte into it's decimal representation. For example the byte
10000000
I would need to convert to -128
and the byte
01111111
I would need to convert to 127
. I've looked at this answer, but I haven't been successful with taking one of the answers and making it work for me.
How do I go about doing the conversion?
CLARIFICATION: I'm trying to convert a byte
in two's complement form into an int
and not a string
representation of a binary value into an `int.