• missing xbfish.com image

Tag Archives: 2 comeplement

Converting 2-complement to decimal

To convert a decimal to 2-complement (2s), you first convert the decimal to binary and invert the bit. From there, you plus one and that would be the 2s of the decimal.

For example, a decimal 5 in binary would be: 0101 (in 4 bits)

The 2-complement of 5, which is -5, is:

First step: Invert the bits of 5 in binary -> 1010

Second step: Plus one to the inverted bits -> 1011

Hence, the 2-complement of 5 would be 1011

Now, to convert a 2-complement back to a decimal….

The algorithm is as follows:

“If it is positive, simply convert it to decimal. If it is negative, make it positive by inverting the bits and adding one. Then, convert the result to decimal. The negative of this number is the value of the original binary.” quoted from Mississippi College.

For example, convert 1101 to decimal.

First step: The sign bit of 1101 shows that it’s a negative decimal. Hence, we invert the bits -> 0010

Second step: We add one to the inverted bits -> 0011

0011 in decimal is 3. The negative of 3 is -3. Hence, the original binary value of 1101 is -3.