**Contents:**

- What are Signed and Unsigned Data Representation?
- Unsigned Binary Numbers
- Signed Binary Numbers
- Disadvantages of Signed-Magnitude Representation
- Signed 1’s Complement Representation
- Advantages and Disadvantages of 1’s Complement
- Signed 2’s Complement Representation
- Advantages of 2’s Complement

## What are Signed and Unsigned Data Representation?

Signed representation is a kind of data representation where we can have both positive and negative numbers. Unsigned data representation signifies a system that shows only positive numbers and negative numbers do not exist.

For any number system, we can use both signed and unsigned representations. We use signed numbers when we have to work with negative numbers as well.

Here is a figure which shows the further classifications of signed and unsigned data representation.

As shown in the figure, signed numbers can be represented using signed-magnitude, 1’s complement, and 2’s complement Representations.

## Unsigned Binary Numbers

The normal form used until now in Binary numbers was its unsigned form. Here are the points related to representing binary numbers as unsigned numbers.

- In unsigned numbers, all the bits represent the value of the number, there is no bit dedicated for the sign, as all numbers are only positive.
- For an n-bit binary number, its value can vary from 0 to (2
^{n}-1). For example, a 4-bit binary number can have values from 0 to (2^{4}-1) = 0 to 15. - Numerically in binary, the unsigned numbers range from (000…n-bit) to (1111…n-bit). All bits when taken as 1 will give the maximum unsigned binary number.
- For unsigned binary numbers, numerically larger numbers can be represented as all the bits represent values.
- It is not ambiguous. All numbers can be written in only one way.

## Signed Binary Numbers

We write the positive numbers in binary as we would in unsigned numbers and for negative numbers, we write its positive number and simply put an extra 1 in front of it. Here are the points related to the signed binary number.

- In signed n-bit binary numbers, one bit that is the MSB is reserved for representing the sign of the number. This is the key difference between signed and unsigned representation.
- A 0 in the MSB represents positive numbers and a 1 in the MSB represents negative numbers.
- Only n-1 bits can represent the value of the number as 1 bit is reserved for the sign.
- This way of representation is known as signed-magnitude representation.
- For a n-bit binary number using signed representation, its value can range from -(2
^{n-1}-1) to + (2^{n-1}-1). For example, a 4-bit number can have values from -(2^{3}-1) to (2^{3}-1) = -7 to +7.

Here is a table that shows signed numbers for 4-bit binary.

0 – 1 0 0 0 | 0 – 0 0 0 0 |

-1 – 1 0 0 1 | 1 – 0 0 0 1 |

-2 – 1 0 1 0 | 2 – 0 0 1 0 |

-3 – 1 0 1 1 | 3 – 0 0 1 1 |

-4 – 1 1 0 0 | 4 – 0 1 0 0 |

-5 – 1 1 0 1 | 5 – 0 1 0 1 |

-6 – 1 1 1 0 | 6 – 0 1 1 0 |

-7 – 1 1 1 1 | 7 – 0 1 1 1 |

As shown in the table, the negative numbers have 1 as their MSB and the positive numbers have 0 as their MSBs.

## Disadvantages of Signed-Magnitude Representation

The disadvantages of using signed-magnitude representation are: –

- There are two representations for zero, -0 (1000) and 0 (0000) which is undesired.
- If we want to expand the number of bits for representation from 4-bits to 8-bits, we would need to insert additional zeroes after the sign bit of MSB to do so. This is expensive in terms of computer hardware. For example, -6 in 8 bits will be 10000110.
- Using the same number of bits as unsigned representation, the largest number that can be represented in signed is smaller.

To cope up with the first two disadvantages, we try out the 1’s complement form to represent binary negative numbers.

## Signed 1’s Complement Representation

To find 1’s complement of a binary number, we invert all the digits of the given number, we change all zeros to ones and all ones to zeros. For example, the 1’s complement of 1100010 is 0011101.

Here are the points related to representing negative numbers in binary using 1’s complement: –

- To represent the negative of a given number, we take out its 1’s complement. For example, 0011 is 3 in binary, so its complement 1100 will represent -3.
- For n-bit binary number, here also like signed-magnitude representation we can represent values from -(2
^{n-1}-1) to + (2^{n-1}-1)

Here is a table that shows 4-bit binary numbers and their negatives using 1’s complement.

-0 – 1 1 1 1 | 0 – 0 0 0 0 |

-1 – 1 1 1 0 | 1 – 0 0 0 1 |

-2 – 1 1 0 1 | 2 – 0 0 1 0 |

-3 – 1 1 0 0 | 3 – 0 0 1 1 |

-4 – 1 0 1 1 | 4 – 0 1 0 0 |

-5 – 1 0 1 0 | 5 – 0 1 0 1 |

-6 – 1 0 0 1 | 6 – 0 1 1 0 |

-7 – 1 0 0 0 | 7 – 0 1 1 1 |

As shown in the table, all the negative numbers have been represented using inverted values of their positive numbers. Values from -7 to +7 can be represented using 4 bits in signed 1’s Complement Representation.

## Advantages and Disadvantages of Using 1’s Complement

The advantages and disadvantages of using 1’s Complement Representation are stated below.

**Advantages**- If we need to expand the number of bits, for example from 4-bits to 8-bits, we only need to copy the MSB for that many new bits to the right of MSB.
- Copying is less expensive compared to the insertion of bits in between. For example, -6 will become 11111001 in 8-bits from 1001 in 4-bits.
**Disadvantages**- Zero still has two representations of 0 (1111) and -0 (0000).

Thus, 1’s complement was able to remove just one disadvantage. So, we switch to 2’s complement for representing negative numbers.

## Signed 2’s Complement Representation

To find out the 2’s complement of any given number, we take out its 1’s complement and then add 1 to this result. For example, 4 in binary is written as 0100

its 1’s complement is 1011

its 2’s complement is 1011 + 1 = 1100.

Here are the points related to signed 2’s complement representation: –

- In signed 2’s complement, a negative number is represented by finding 2’s complement of its positive number.
- For an n-bit binary number, we can represent values from -(2
^{n-1}) to + (2^{n-1}-1) using 2’s complement.

Here is a table that shows 4-bit binary numbers and their negatives using 1’s complement.

0 – 0 0 0 0 | 0 – 0 0 0 0 |

-1 – 1 1 1 1 | 1 – 0 0 0 1 |

-2 – 1 1 1 0 | 2 – 0 0 1 0 |

-3 – 1 1 0 1 | 3 – 0 0 1 1 |

-4 – 1 1 0 0 | 4 – 0 1 0 0 |

-5 – 1 0 1 1 | 5 – 0 1 0 1 |

-6 – 1 0 1 0 | 6 – 0 1 1 0 |

-7 – 1 0 0 1 | 7 – 0 1 1 1 |

-8 – 1 0 0 0 | – |

As shown in the table, using 4-bits, we can represent values from -8 to 7 in 2’s complement form.

## Advantages of Using 2’s Complement

The advantages of using 2’s complement are listed below: –

- Zero has just one representation of 0000 as on adding 1 to its 1’s complement (1111), it becomes a 5-bit number and the 5-th bit is said to fall off. (1111 + 1 = 10000). So, the ambiguity is removed.
- It can represent one more value than 1’s complement form.
- For expanding the number of bits, we have retained the method of copying the MSB to its right for the new bits. For example, -5 in 8-bits and 2’s complement form will be represented as 11111011 from 1101 in 4-bits.

Thus, by using 2’s complement to represent negative numbers, we overcame all the disadvantages faced in representing both positive and negative numbers in earlier forms.

## Key Points to Remember

Here are the key points to remember in “Signed and Unsigned Binary Numbers”.

- Unsigned representation means only representing positive numbers and signed representation means showing both positive and negative numbers.
- Signed-magnitude, 1’s Complement, and 2’s Complement Representations are the 3 ways to represent signed numbers.
- In signed-magnitude representation, we reserve the MSB to represent the sign of a number. 0 as the MSB means a positive number while 1 as the MSB means a negative number.
- In 1’s Complement Representation, we represent a negative number by inverting all of its bits.
- Signed-magnitude representation as well as 1’s Complement gives two values of 0s and thus is ambiguous.
- In 2’s Complement Representation, we represent negative numbers by adding 1 to its positive number’s 1’s Complement form.
- The ambiguity of two representations for zeros is removed using 2’s Complement form.

**If you find any mistake above, kindly email to [email protected]**