1

The question is to find the 2's complement of the binary number (-00101.110) in 8 bits.

So I don't understand what to do with the fractional part. I think the 1's complement will be 11010.001 Is 11010.010 the 2's complement? And are these the 8 bits that I need as my final answer of the 2s complement of -00101.110?

user1869703
  • 53
  • 3
  • 7

1 Answers1

1

In two's complement notation, all of the most significant bits of a negative number are set to 1. Let's assume you're storing these numbers as 8 bits, with 2 to the right of the "binary point."

By definition, x + -x = 0, so we can write:

0.5  +  -0.5 = 0.10 + 111111.10 = 0   // -0.5  = 111111.10
0.25 + -0.25 = 0.01 + 111111.11 = 0   // -0.25 = 111111.11
0.75 + -0.75 = 0.11 + 111111.01 = 0   // -0.75 = 111111.01

and so on.

Using 8 bits like this, the largest number you can store is

011111.11 = 31.75

the least-positive number is

000000.01 = 0.25

the least-negative number is

111111.11 = -0.25

and the smallest (that is, the most negative) is

100000.00 = -32

Source

With decimal number systems we are use to having a units, tens and hundreds columns, with unsigned binary numbers this becomes 1,2,4 etc 2 to the power of column number.

For example

2^0 (1), 2^1 (2), 2^2 (4).

In Twos-complement the most significant bit (MSB) becomes negative. For a three bit number the rows would hold these values;

-4, 2, 1
 0  0  1 => 1
 1  0  0 => -4
 1  0  1 => -4 + 1 = -3

So the value of the bits held by a fixed-point system is unchanged.

-1 will always be 111.000

-0.5 add 0.5 to it: 111.100

In your case 110100.10 is equal to -32+16+4+0.5 = -11.5. What you did was create -12 then add 0.5 rather than subtract 0.5.

What you actually want is -32+16+2+1+0.5 = -12.5 = 110011.1

Community
  • 1
  • 1
Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115
  • I still dont understand it quite too well. My book has an example where it says the fraction 0.01 (base 2) has a complement of 1.10 (base2) and two's complement of 1.11 (base 2). So I went off of that for my problem. – user1869703 Jan 22 '14 at 05:08