# convert Hex value to two's Complement

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?

• Short answer is that you cannot. A signed 8-bit integer must fall into a limited range which excludes +229 from the possible values. Of course there is an unsigned 8-bit integer that could represent this value. – hardmath Feb 7 '16 at 19:33
• With 8 bits, two's complement format can only represent integers in the range $-128$ to $+127$. You're trying to represent 0xE5 = 229. – fgp Feb 7 '16 at 19:34
• does this equation always give the rage? : -2^[(n-bit) -1] to [2^(n-bit) -1] - 1] ? – Makaveli Feb 7 '16 at 19:40

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.