I understand that 2's complement solves the issues of sign magnitude when adding/subtracting numbers, and has one representation for 0. I also know it is an easier way to deal with negative numbers, but I still don't understand the difference in theory.
They both use the most significant bit as a sign representation, but how does 2's complement differ and resolve the issues?
Turn on thread page Beta
What's the difference between sign-magnitude and 2's complement? watch
- Thread Starter
Last edited by _howl; 06-11-2016 at 14:20.
- 06-11-2016 14:14
- 07-11-2016 21:02
Sign-magnitude has the first bit saying whether or not it's positive or negative (the sign) and the rest of the bits saying the number itself (the magnitude). This obviously means you would have a +0 and a -0
While twos complement simply represents the number normally if it's positive (same as sign magnitude), but if it's negative, it minuses 1 and then bitwise inverts it. For example, with only 3 bits, DEC -3 is represented as 101. Since you start with 3 (011), you minus one (010) and then invert it (101). The key point here is the fact that you minus one. This means that BIN 100 represents BIN - 011 + 1 = = - 100 = DEC -4. The fact that it minuses one means that you are using that extra 0 as an actual number (the highest possible number) rather than just another 0.