A Complete Guide to Signed 2's Complement Form of Signed Numbers

What is the 2’s Complement Form?

The 2’s complement form is the most widely used method for representing signed numbers in binary systems. It encodes both positive and negative numbers in a way that simplifies arithmetic operations like addition and subtraction. Positive numbers are represented as standard binary numbers with the most significant bit (MSB) set to 0. Negative numbers are formed by taking the 1’s complement (bitwise inversion) of the positive number and adding 1, resulting in an MSB of 1. For an n-bit number in 2’s complement, one bit indicates the sign, and the remaining n-1 bits represent the magnitude or its complement. This system is favored in modern computing for its efficiency and single representation of zero.

Representing Numbers in 4-Bit 2’s Complement Form

In a 4-bit 2’s complement representation, one bit is reserved for the sign, leaving three bits for the magnitude. This allows numbers from \(\mathsf{-8}\) to \(\mathsf{+7}\) to be represented. Positive numbers are written directly in binary with a \(\mathsf{0}\) sign bit (e.g., \(\mathsf{+5}\) is \(\mathsf{0101}\)). To represent a negative number, take the positive number’s binary form, invert all bits (1’s complement), and add \(\mathsf{1}\) (e.g., \(\mathsf{-5}\) is derived from \(\mathsf{0101}\): invert to \(\mathsf{1010}\), add \(\mathsf{1}\) to get \(\mathsf{1011}\)). Unlike signed magnitude and 1’s complement, 2’s complement has a single representation for zero (\(\mathsf{0000}\)), eliminating ambiguity and simplifying arithmetic operations.

this image shows the comparison table of 4-bit signed binary numbers in signed magnitude, signed 1's complement and signed 2's complement forms and their equivalent numbers

Range of Numbers Stored in n-Bits

The range of numbers in 2’s complement form for n bits is determined by the \(\mathsf{n-1}\) bits available for the magnitude, with a slight asymmetry due to the single zero representation. The range spans from \(\mathsf{-2^{n-1}}\) to \(\mathsf{+2^{n-1} – 1}\). For example:

  • For \(\mathsf{4}\) bits (\(\mathsf{n=4}\)), the range is \(\mathsf{-8}\) to \(\mathsf{+7}\).
  • For \(\mathsf{8}\) bits (\(\mathsf{n=8}\)), the range is \(\mathsf{-128}\) to \(\mathsf{+127}\).
this image shows the comparison table of signed binary numbers in signed magnitude, signed 1's complement and signed 2's complement forms and their allowable ranges for n = 2 to n = 32

This range differs from signed magnitude and 1’s complement, as 2’s complement includes one additional negative number. A comparison of ranges across different signed number representations is available in the referenced figure on other pages.

Advantages and Limitations of 2’s Complement Form

Advantages

  • Single Zero Representation: Having only one representation for zero (\(\mathsf{0000}\)) eliminates ambiguity and simplifies arithmetic.
  • Simplified Arithmetic: Addition and subtraction are performed uniformly, with no need for special handling of signs or end-around carries.
  • Wide Adoption: 2’s complement is the standard in modern computing due to its efficiency in hardware and software implementations.

Limitations

  • Asymmetric Range: The range includes one more negative number than positive, which can be counterintuitive in some applications.
  • Overflow Risk: Arithmetic operations may lead to overflow, requiring careful detection (covered in detail on the overflow page).

Why Understand 2’s Complement?

The 2’s complement form is the cornerstone of binary arithmetic in modern digital systems, used in CPUs, programming languages, and digital circuits. Understanding it is essential for performing efficient and accurate arithmetic operations, such as addition and subtraction, and for handling overflow conditions. By mastering 2’s complement, you’ll gain a critical skill for computer science and digital electronics. For further details, explore the related pages:

By grasping the 2’s complement form, you’ll unlock a deeper understanding of how computers handle signed numbers, enhancing your ability to work with binary arithmetic effectively.