Range of Integers Representable by nn-bit Two’s Complement

Range of Integers Representable by nn-bit Two’s Complement

Verified Sources
Nov 3, 2026

In an nn-bit two’s complement representation, the most significant bit (MSB) acts as the sign bit, and there are 2n2^n distinct bit patterns total. The set of representable signed integers is:

  • Minimum: −2n−1-2^{n-1}
  • Maximum: 2n−1−12^{n-1}-1

So the representable range is −2n−1  ≤  x  ≤  2n−1−1.-2^{n-1} \;\le\; x \;\le\; 2^{n-1}-1.

Key ideas:

  • Two’s complement encodes negatives using modular arithmetic on 2n2^n.
  • MSB (most significant bit) determines whether a bit pattern is interpreted as nonnegative or negative.
  • Sign extension preserves the numeric value.

Note: The range formula above is the standard result for two’s complement encodings, widely used in computer architecture and digital logic.

Two's Complement Representation and Range

Deriving the range (conceptual proof)

Let bits be bn−1bn−2…b1b0b_{n-1}b_{n-2}\dots b_1b_0, where bn−1b_{n-1} is the MSB. Two’s complement interprets the bit string as a signed value via a weighted sum: x=−bn−1⋅2n−1+∑i=0n−2bi⋅2i.x = -b_{n-1}\cdot 2^{n-1} + \sum_{i=0}^{n-2} b_i\cdot 2^i.

From this:

  • If bn−1=0b_{n-1}=0 (nonnegative), then the sum is maximized when all remaining bits are 1: xmax⁡=∑i=0n−22i=2n−1−1.x_{\max} = \sum_{i=0}^{n-2} 2^i = 2^{n-1}-1.
  • If bn−1=1b_{n-1}=1 (negative), the most negative value occurs when all remaining bits are 0: xmin⁡=−2n−1.x_{\min} = -2^{n-1}.

Therefore: x∈[−2n−1,  2n−1−1].x \in \left[-2^{n-1},\; 2^{n-1}-1\right].

Key terms:

  • [Modular arithmetic]{def="Working with integers modulo a fixed value such as 2n2^n"} explains why bit patterns wrap around.
  • Integer encoding clarifies “representation range.”
  • Bit pattern.

Quick check for $n$-bit two’s complement

Compute −2n−1-2^{n-1} and 2n−1−12^{n-1}-1. If you ever get a symmetric range around 0, re-check: two’s complement has one extra negative value.

Common mistake: assuming $[-2^{n-1}, 2^{n-1}]$

Two’s complement does not represent +2n−1+2^{n-1}. The maximum is 2n−1−12^{n-1}-1, while the minimum is −2n−1-2^{n-1}.

Compute the representable integer range for $n$-bit two’s complement

  1. 1
    Step 1

    Start with xmin⁡=−2n−1x_{\min}=-2^{n-1} and xmax⁡=2n−1−1x_{\max}=2^{n-1}-1.

  2. 2
    Step 2

    Express the range as −2n−1≤x≤2n−1−1.-2^{n-1}\le x\le 2^{n-1}-1.

  3. 3
    Step 3

    For n=8n=8: xmin⁡=−27=−128,xmax⁡=27−1=127.x_{\min}=-2^7=-128,\quad x_{\max}=2^7-1=127.

  4. 4
    Step 4

    Confirm the MSB indicates sign; use sign extension if you change bit-width.

Examples for intuition

n=4n=4 (4-bit two’s complement)

  • Minimum: −23=−8-2^{3} = -8
  • Maximum: 23−1=72^{3}-1 = 7

So the range is: −8≤x≤7.-8 \le x \le 7.

n=8n=8 (8-bit two’s complement, common in bytes)

  • Minimum: −27=−128-2^{7} = -128
  • Maximum: 27−1=1272^{7}-1 = 127

So the range is: −128≤x≤127.-128 \le x \le 127.

How the range emerges as you increase bit-width

Very small width

n = 2

Range: −21=−2-2^{1}=-2 to 21−1=12^{1}-1=1."

Wider signed range

n = 4

Range: −23=−8-2^{3}=-8 to 23−1=72^{3}-1=7."

Byte-sized integers

n = 8

Range: −128-128 to 127127."

Closed-form solution

General n

Always: [−2n−1, 2n−1−1][-2^{n-1},\,2^{n-1}-1]."

Representable range endpoints for selected n

Minimum is −2n−1-2^{n-1}; maximum is 2n−1−12^{n-1}-1.

FAQs and edge cases

Two’s complement range quick recall

1 / 5
Question · Term

What is the minimum value representable with $n$ bits?

Click to reveal
Answer · Definition

Minimum is −2n−1-2^{n-1}.

Knowledge Check

Question 1 of 4
Q1Single choice

For nn-bit two’s complement, which pair correctly gives the minimum and maximum representable integers?