Course contentsShow
Computer Science
Lesson 10 of 2,8721. Digital FoundationsFree lesson

Signed Integer Representation

Learn sign-magnitude, one's complement, and two's complement methods for representing negative numbers.

Signed Integer Representation

What you'll learn: How computers store both positive and negative numbers using sign-magnitude, one's complement, and two's complement methods.

Why We Need This

So far, you've worked with binary numbers that are always positive. But computers need to represent negative numbers too—like temperatures below zero or money owed. Since computers only understand 1s and 0s, we need special schemes to indicate whether a number is positive or negative.

Three Methods for Representing Signed Integers

Sign-Magnitude

The leftmost bit becomes a "sign bit": 0 means positive, 1 means negative. The remaining bits represent the magnitude (size) of the number.

  • 01010 = +10 in decimal
  • 11010 = -10 in decimal

Problem: This gives us two representations of zero (00000 and 10000), which is awkward for calculations.

One's Complement

To make a number negative, flip all the bits (change 0s to 1s and 1s to 0s).

  • 01010 = +10
  • 10101 = -10 (all bits flipped)

Problem: Still has two zeros (00000 and 11111), and addition requires special handling.

Two's Complement (Most Common)

To make a number negative: flip all bits, then add 1.

  • 01010 = +10
  • Flip: 10101
  • Add 1: 10110 = -10

Why it's best: Only one zero, and regular binary addition works naturally with negative numbers—no special cases needed!

The leftmost bit still indicates sign (0 = positive, 1 = negative), but the pattern is more mathematically elegant.

Key Takeaway: Computers use different schemes to represent negative numbers in binary; two's complement is the standard because it has one zero and makes arithmetic simple.