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:
This is a simple approach that adds an extra bit (i.e., sign-bit) to detect the sign of a number. indicates a -ve number, and indicates a +ve number or vice versa (depending on the architecture of the computer).
For example, if 2 then 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.
In this representation, the left-most bit is considered to be the sign-bit (without adding an extra bit), where is a -ve and is a +ve. This reduces the range of positive numbers that can be represented (using bits) from to . 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 .
Free Resources