Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two's Complement disadvantage?

I was reading about two's complement, I understand this method is most efficient, but there might be some disadvantages too. I could not find any disadvantages, Is there any situation where the conversion to two's complement could fail to represent the number correctly?

like image 838
user845405 Avatar asked Sep 23 '13 05:09

user845405


2 Answers

Two's complement is awesome - that's why everyone uses it. The biggest disadvantage is that if you try to negate the lowest representable value, you get an overflow. With one's complement or sign and magnitude, that doesn't happen.

like image 196
user2357112 supports Monica Avatar answered Dec 20 '22 08:12

user2357112 supports Monica


With "two complement"-notation you can't compare the size of two Integers with very simple logic operators (at lowest level hardware). Thats the reason why the exponent in IEEE Standard for Floating-Point Arithmetic (IEEE 754) is not represented in "two complement" but in "biased" notation.

like image 26
user__42 Avatar answered Dec 20 '22 09:12

user__42