-4

So let me get this straight, just started learning about two's compliment etc,

anyway I got a binary number 10101011 which is 171

I was told to find the 8 bit one's and two's compliment of this number...

I put 84 and 85 respectively...

Is this correct can someone verify this, i used the obvious method of inverting the binary for the one's and adding one to the least important bit to acquire the two's compliment.

Thanks in advance for any clarification,

Sim

4

1 に答える 1

3

Ones' complement and two's complement are systems for representing negative numbers. Your number is a positive number.

Ones' complement: Flip all of the bits; replace 1's with 0's and 0's with 1's.

For example, consider the number -32. The ones' complement of -32 is the binary value of 32, with all of the bits flipped:

 32 == 00100000
-32 == 11011111

Two's complement: Same as ones' complement, followed by adding 1.

 32 == 00100000
-32 == 11100000
于 2013-03-05T00:47:27.137 に答える