Related Tags

binary
architecture
number
arithmetic

# How to represent negative binary numbers

Since computers only understand binary numbers but need to perform operations involving negative numbers, there is a way to represent negative numbers (like positive numbers) in a binary format. A negative binary number can be made from its positive version in the following two ways:

## 1. Sign and magnitude

This is a simple approach that adds an extra bit (i.e., sign-bit) to detect the sign of a number. $1$ indicates a -ve number, ​and $0$ indicates a +ve number or vice versa (depending on the architecture of the computer).

For example, if $7 = (0111)$2 then $-7 = (1111)$2.

A drawback is that the adders, in the underlying hardware of the computer, need to determine the sign-bit of an operation’s result. Due to this, and other disadvantages, the sign-bit representation of negative numbers is now obsolete.

## 2. Two’s complement

In this representation, the left-most bit is considered to be the sign-bit (without adding an extra bit), where $1$ is a -ve and $0$ is a +ve. This reduces the range of positive numbers that can be represented (using $n$ bits) from $2^n - 1$ to $2^{n-1} - 1$. Despite this drawback, it is now the standard way of representing negative binary numbers.

To convert a positive number into a negative number, using the two’s complement representation, invert all of the bits of the number and ​add $1$.

RELATED TAGS

binary
architecture
number
arithmetic