Monday, August 13, 2012

1's complement and 2's complement why you need




Subtract from the computer calculation is very difficult circuit.
Only plus routine swipgoyo.
So, to use as a shortcut for addition subtraction is to use a conservative.

To give an example with a 4-bit, for example, would be happy to explain.
For the first description of repair of thumb
1's complement of 0 to 1 is the conversion of 1 to 0.
Thus, the 1's complement of the number 7
7, 0111 in binary (4 bits is if any).
This is the 1's complement of 1000.
Two's complement of the one plus one is to repair.
Doejiyo 1000 + 1 = 1001.

1's complement and two's complement 1001 1000 -11 are intended to represent both.

I'll try to decimal subtraction.
Is 4-2 = 2. If you switch to this format, plus
4 + (-2) = 2. So in order to display the binary representation of 4 and -2 when plotted

4 = 0100
-2
=> 0010 (decimal +2)
=> 1101 (1's complement.)
=> 1110 (2's complement: 1's complement +1)

4 + (-2)
=> 0100 + 1110
=> 10010
=> 0010 (4 bits onto one bit since abandoned).
=> 2 (converted to decimal)

In this way, a subtraction operation to addition operation will be able to handle.


So why use a lot of two's complement ideas?
It displays the number of numbers that is.
0, 1's complement and two's complement representation of
0000 (4 bit 0)
1111 (1's complement 0)
10000 (two's complement: 1's complement + 1)
0000 (two's complement: 4 bits for handling a bit before discarding)

In the example above
0 to represent the 1's complement of the 0000, 1111 are both 0. Ten thousand in two's complement 0000 0 agent.
This can be displayed as a byte (8 bits) per number of size
If one of the bosuin: -127 - 127 => 255 total
Bosuin 2: -128 to 127 => 256 total
Take the two's complement number, so no one can be displayed due will be.

Of course, the two's complement yijiyo more efficient.

No comments:

Post a Comment