2.1.2 Unsigned and two's complement integers

Unsigned Binary Integers

An unsigned binary integer represents only non-negative values (zero and positive). Each bit position has a place value that is a power of 2, increasing from right to left. The value of the number is the sum of all place values where there is a 1.

8-bit column values

Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
1286432168421

Example: convert 10110101 to denary.

1286432168421
10110101

128 + 32 + 16 + 4 + 1 = 181

With 8 bits unsigned, values range from 0 (00000000) to 255 (11111111), giving 2⁸ = 256 different values.

Representing Negative Numbers: Two's Complement

Unsigned binary cannot represent negative numbers. Two's complement is the standard method for representing signed integers (positive and negative) in binary. It uses the most significant bit (MSB — the leftmost bit) as a sign bit, but with a twist: the MSB has a negative place value.

8-bit two's complement column values

Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
−1286432168421

Positive values (and zero) have bit 7 = 0. They work identically to unsigned binary.

Example: 01001010 = 0 + 64 + 0 + 8 + 0 + 2 + 0 = +74

Negative values have bit 7 = 1. The MSB contributes −128 and the remaining bits add positive contributions as usual.

Example: 11001010 = −128 + 64 + 0 + 8 + 0 + 2 + 0 = −54

Example: 10000000 = −128 + 0 + … + 0 = −128

Example: 11111111 = −128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = −128 + 127 = −1

To convert a positive number to its negative equivalent (or vice versa): invert all bits, then add 1.

Example: represent −35 in 8-bit two's complement.

  1. Start with +35: 00100011
  2. Invert all bits: 11011100
  3. Add 1: 11011100 + 00000001 = 11011101

Verify: −128 + 64 + 16 + 8 + 4 + 1 = −128 + 93 = −35

BitsUnsigned rangeTwo's complement range
4 bits0 to 15−8 to +7
8 bits0 to 255−128 to +127
16 bits0 to 65,535−32,768 to +32,767

Two's complement always gives one more negative value than positive. This is because zero occupies one of the positive-side slots.

Why Two's Complement?

Two's complement has a key practical advantage: the same addition circuitry works for both positive and negative numbers without any special cases. For example, −35 + 35 in 8-bit two's complement:

  11011101   (−35)
+ 00100011   (+35)
──────────
 100000000   = 0 (the 9th bit overflows out of 8 bits, leaving 00000000)

The result is 0, as expected. No special subtraction circuit is needed.

 Key Takeaways

  • Unsigned binary represents 0 and positive integers only; place values are powers of 2.
  • Two's complement represents signed integers; the MSB has a negative place value (−2^(n−1)).
  • To negate: invert all bits, then add 1.
  • 8-bit unsigned: 0 to 255; 8-bit two's complement: −128 to +127.
  • Two's complement allows addition and subtraction to use the same hardware circuit.