[Math] convert Hex value to two’s Complement

binarydiscrete mathematicseducation

for example, let's say: 0xE5

assume the system is 8 -bit
in decimal it's = 229
and in Binary it's = 1110 0101

the Two's Complement rules said: sign-bit, which's the most left, indicates a negative value if it's "1", or if it's "0" the value is positive.

so, the value is positive, but the Binary representation indicates in left-most bit as "negative" value!

I'm totally confused… how can i show the correct representation in two's Complement format in 8-bit system?

Best Answer

When using 2-complementary, the range of 8 bits integer is $-128<= n <= 127$. When you have a number 0xE5, once it is binary form, it is a negative number. The two's complentary of this number is a positive number, and add negative sign to it, that is the decimal number (negative) for 0xE5 for the system using two's complementary.

once you flip bits, you should add 1 to it.