# two's complement

• Jan 26th 2011, 03:26 AM
nameck
two's complement
Perform the following arithmetic operation using 8-bit
two's complement

a) 8710 - 2910

i just want to know.. am i converting the number correctly?

89 = 0101 1001
-29 = 1110 0011

or...

i should change from decimal to binary...
then, apply two's complement to the number?

i know how to perform the arithmetic.. just bit confused with the representation of the number..
• Jan 26th 2011, 08:22 AM
chiph588@
\$\displaystyle 29_{10} = 00011101_2 \$. To get \$\displaystyle -29 \$ invert the digits and add one.

\$\displaystyle (-29)_{10} = (11100010+1)_2 = 11100011_2 \$, so yes you are correct.
• Jan 26th 2011, 02:06 PM
The idea behind 2's complement arithmetic is to represent 29 as a negative binary number

\$\displaystyle 89-29=80+(-29)\$

In binary, \$\displaystyle 29=2^4+2^3+2^2+2^0=00011101_2\$

To write \$\displaystyle -29\$ in 2's complement form, invert the bits and add 1.

8-bit negative numbers have a 1 in the most-significant bit position.
Positive numbers have a 0 there.

\$\displaystyle 01011001_2+11100011_2=00111100_2\$

with a carry into the 9th bit position, which means the result is positive.

The result should be 60.

\$\displaystyle 00111100_2=2^2+2^3+2^4+2^5=4+8+16+32=60\$