Representation of negative integers in binary 2's complement system

264 Views Asked by At

I have some confusion regarding the representation of negative integers in 2's complement binary form. For example I want to convert -5 to binary:

+5= 00000101
1's complement of 5: 11111010
2's complement of 5: 11111011
-5= 11111011

is the above process right? or will I have to add and additional 1 at the MSB position to represent -5 (111111011)?

1

There are 1 best solutions below

0
On

The representation of negative quantities in a binary system requires a clear definition of the word length, i.e., of the maximum number of bits allowed by the representation.

In your case $11111011$ is a valid representation of $-5$ in an $8$ bit system. Had the system used more bits, you would have to extend the result adding $1s$ to the left until you reach the word length.

Keep in mind that $2's$ complement is nothing but the representation of a negative number by its non-negative reminder $\mod r$, being $r$ the power of $2$ to the word length.