JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat (newest first)  | Threaded  | Tree Previous Thread  |  Next Thread Forums Tutorial Discussions Representation of Integers and Reals Tutorial Why two's complement
 Why two's complement | Reply Is it to avoid positive and negative zero?
 Re: Why two's complement (response to post by FalconsGaze) | Reply The biggest reason is that if you're working in two's complement, you can add negative numbers without having to code any annoying logic. Say we were working on a 4-bit processor :)In two's complement, 3 = 0011 and -1 = 1111. Added together and discarding the high bit, we have 0010 = 2, which is the right answer. In one's complement, we'd have 0011 and 1001. To get the right answer here, we'd have to special case the high (sign) bit, and then also call the subtraction routine instead. This is a lot of hassle, and is also slower when you get down to the logic gate level.
 Re: Why two's complement (response to post by FalconsGaze) | Reply Also note that two's complement is just Z mod some power of 2.
 Forums Tutorial Discussions Representation of Integers and Reals Tutorial Why two's complement Previous Thread  |  Next Thread