World's most popular travel blog for travel bloggers.

Why is a negative number a pseudo-positive number in ones' complement?

, , No Comments
Problem Detail: 

I'm studying ones' complement representation and I read in a book that a negative number in ones' complement is a pseudo-positive of value $R^n - 1 - |x|$.

However there is no demostration and I can't find it anywhere. If someone could tell me the reason I will be very thankful.

Asked By : Joseph

Answered By : David Richerby

One's complement stores negative numbers as their bitwise negation.

Suppose we're working in $b$ bits. A positive integer $x$ is represented in binary by writing it as $x = \sum_{i=0}^b a_i2^i$, where each $a_i\in\{0,1\}$. The bitwise negation of $x$, then, is $$\overline{x} = \sum_{i=0}^b (1-a_i)2^i = \sum_{i=0}^b 2^i - \sum_{i=0}^b a_i2^i = 2^b - 1 - x\,.$$

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/44300

3200 people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback