Course contentsShow
← Computer Science
Lesson 1058 of 2,87225. Computer Architecture FoundationsFree lesson

One's Complement Representation

An alternative signed integer format where negative numbers are bitwise complements of their positive counterparts.

What You'll Learn

You'll learn an alternative way computers can represent negative integers by flipping all the bits of a positive number.


What Is One's Complement?

One's complement is a method for representing signed integers where a negative number is formed by inverting every bit (changing 0s to 1s and 1s to 0s) of its positive counterpart.

Think of it like a photographic negative: everywhere the original was bright becomes dark, and vice versa. In binary, every bit position flips to its opposite.

How It Works

If you have a positive number, say +5 in 8-bit binary:

0000 0101  (decimal 5)

To get -5 in one's complement, flip every bit:

1111 1010  (one's complement -5)

The leftmost bit still acts as a sign indicator (0 for positive, 1 for negative), just as in sign-magnitude representation, but the remaining bits aren't simply a magnitude anymore—they're the bitwise complement.

Key Characteristics

  • Range: For n bits, you can represent values from -(2^(n-1) - 1) to +(2^(n-1) - 1)
  • Two zeros: Unlike what you might expect, one's complement has both +0 (all zeros: 0000 0000) and -0 (all ones: 1111 1111), which is awkward for hardware
  • Symmetric: Every positive number has an exact negative counterpart created by bit inversion

Why It Matters

One's complement was used in some early computers because negation is trivial (just flip bits), but the dual-zero problem made arithmetic circuits more complex. Modern systems favor two's complement, which you'll learn next.

Key Takeaway: One's complement represents negative numbers by inverting all bits of the positive version, creating a symmetric but quirky system with two representations of zero.