Free Tool Two’s Complement Signed Range Exact BigInt

Two’s Complement Range Calculator

Calculate the exact minimum and maximum value for any n-bit two’s-complement signed integer. Inspect sign-bit weight, negative and nonnegative capacity, boundary binary patterns, hexadecimal limits, and standard or custom integer widths.

Min & max
Sign-bit weight
Binary + hex
1–1024 bits
8-bit two’s-complement limits
Minimum 10000000 = -128
Maximum 01111111 = 127
2C
Two’s-Complement Boundary Analyzer
SIGNED N-BIT
Two’s-complement range −2^(n−1) … 2^(n−1)−1
Two’s-complement range
Minimum signed value -128
Maximum signed value 127
Width 8 bits
Sign-bit weight -128
Negative values 128
Nonnegative values 128
Total patterns 256
Minimum binary pattern 10000000
Maximum binary pattern 01111111
Minimum hex pattern 80
Maximum hex pattern 7F
Overview

What Is a Two’s Complement Range?

The two’s-complement range is the complete set of signed integer values that can be represented by a fixed number of binary bits using two’s-complement encoding.

Two’s complement is the dominant signed integer representation used by modern processors and programming environments. It allows positive, negative, and zero values to share one compact binary encoding without requiring a separate sign-and-magnitude format.

For an n-bit value, the smallest representable number is −2n−1, while the largest is 2n−1 − 1.

2ⁿ Total available bit patterns
−2ⁿ⁻¹ Minimum signed value
2ⁿ⁻¹−1 Maximum signed value
MSB Highest bit carries negative positional weight
Core Formula

Two’s Complement Range Formula

General n-bit formula Two’s complement
Minimum: -2^(n – 1) Maximum: 2^(n – 1) – 1 Total bit patterns: 2^n Negative values: 2^(n – 1) Nonnegative values: 2^(n – 1)

Half of all available bit patterns correspond to negative values. The other half represent zero and positive values.

Sign Bit Weight

Why the Most Significant Bit Has Negative Weight

In ordinary unsigned binary, each bit has a positive positional weight. Two’s-complement encoding changes the interpretation of the most significant bit.

For an n-bit two’s-complement number, the highest bit has weight −2n−1. The remaining bits retain their normal positive binary weights.

8-bit positional weights MSB = -128
Bit weights: b7 b6 b5 b4 b3 b2 b1 b0 -128 64 32 16 8 4 2 1

This negative high-order weight is what allows the same binary addition hardware to work naturally with both positive and negative signed values.

Method

How to Calculate a Two’s-Complement Range

01
Identify the bit width Let n equal the number of bits in the signed representation.
02
Find the sign-bit magnitude Calculate 2^(n−1). The sign bit carries the negative of this value.
03
Negate it for the minimum The minimum value is −2^(n−1).
04
Subtract one for the maximum The largest positive value is 2^(n−1)−1.
Reference

Common Two’s-Complement Ranges

Bits Minimum Maximum Total patterns
4 -8 7 16
8 -128 127 256
16 -32,768 32,767 65,536
32 -2,147,483,648 2,147,483,647 4,294,967,296
64 -9,223,372,036,854,775,808 9,223,372,036,854,775,807 18,446,744,073,709,551,616
Worked Example

8-Bit Two’s-Complement Range

Calculate the 8-bit range int8
n = 8 Sign-bit weight: -2^7 = -128 Minimum: -128 Maximum: 2^7 – 1 = 127 Range: -128 to 127 Minimum binary: 10000000 Maximum binary: 01111111
Boundary Patterns

Minimum and Maximum Binary Patterns

The minimum two’s-complement value always begins with 1 and contains zeros in every lower bit position. The maximum begins with 0 and contains ones in every remaining position.

Width Minimum pattern Maximum pattern
4-bit 1000 0111
8-bit 10000000 01111111
16-bit 1000000000000000 0111111111111111
32-bit 10000000000000000000000000000000 01111111111111111111111111111111
Why Asymmetric?

Why Two’s Complement Has One Extra Negative Value

Two’s-complement ranges are slightly asymmetric. An 8-bit value ranges from −128 to +127 rather than −127 to +127.

There are 256 total bit patterns. Exactly 128 begin with 1 and correspond to negative values. The 128 patterns beginning with 0 represent zero through 127.

128 Negative int8 patterns
1 Pattern reserved for zero
127 Strictly positive patterns
256 Total 8-bit patterns
Signed vs Unsigned

Two’s-Complement Range vs Unsigned Range

Two’s complement

Uses the range −2^(n−1) through 2^(n−1)−1 and includes negative values.

Unsigned binary

Uses every bit for magnitude and ranges from 0 through 2^n−1.

8-bit comparison Same 256 patterns
Two’s complement: -128 to 127 Unsigned: 0 to 255 Both contain: 256 unique bit patterns
Hexadecimal

Two’s-Complement Range Limits in Hexadecimal

Hexadecimal makes two’s-complement boundaries easier to read because one hex digit represents exactly four binary bits.

Width Minimum pattern Maximum pattern
8-bit 80 7F
16-bit 8000 7FFF
32-bit 80000000 7FFFFFFF
64-bit 8000000000000000 7FFFFFFFFFFFFFFF
Custom Widths

Two’s-Complement Ranges for Nonstandard Bit Widths

Two’s complement is not limited to 8, 16, 32, or 64 bits. Packed protocols, DSP data, sensors, ADC output, instruction formats, and embedded registers often use custom widths.

Bits Minimum Maximum
3 -4 3
5 -16 15
10 -512 511
12 -2,048 2,047
24 -8,388,608 8,388,607
Overflow

Two’s-Complement Overflow at the Range Boundaries

A fixed-width two’s-complement value cannot directly represent numbers outside its valid range. Arithmetic that crosses the minimum or maximum boundary may overflow.

For example, an 8-bit signed value cannot directly represent 128. Likewise, −129 is below the minimum representable int8 value.

8-bit boundaries Overflow example
Largest valid: 01111111 = 127 Smallest valid: 10000000 = -128 Outside range: 128 -129
The exact result of signed overflow depends on the language, runtime, compiler, instruction set, and operation being performed. Do not assume identical behavior across all environments.
Practical Uses

Where a Two’s-Complement Range Calculator Is Useful

Embedded Validate signed register limits
Protocols Check signed binary field ranges
Programming Choose safe integer widths
Reverse engineering Interpret raw signed binary data

Sensor values

A 12-bit signed sensor field has a valid two’s-complement range of −2048 through 2047. Knowing that limit helps identify invalid readings or incorrect decoding.

Instruction formats

Immediate values and relative offsets often use signed fields with nonstandard widths. Their minimum and maximum values follow the same two’s-complement formula.

Binary parsers

Range calculations are useful when validating decoded values from files, packets, firmware, telemetry, and custom binary structures.

Common Mistakes

Two’s-Complement Range Mistakes to Avoid

Using −(2^n) as the minimum

The minimum signed value is −2^(n−1), not −2^n.

Using 2^(n−1) as the maximum

The maximum is one less: 2^(n−1)−1.

Treating the range as symmetric

Two’s complement includes one more negative value than strictly positive values.

Confusing a raw bit pattern with its unsigned value

For example, hexadecimal FF is 255 when unsigned but −1 when interpreted as an 8-bit two’s-complement value.

FAQ

Two’s Complement Range Calculator FAQs

Common questions about two’s-complement limits, sign bits, minimum and maximum values, bit widths, hexadecimal boundaries, and overflow.

The range is −2^(n−1) through 2^(n−1)−1.
The 8-bit range is −128 through 127.
The 16-bit range is −32,768 through 32,767.
The 32-bit range is −2,147,483,648 through 2,147,483,647.
The 64-bit range is −9,223,372,036,854,775,808 through 9,223,372,036,854,775,807.
The most significant bit has positional weight −2^(n−1), and the minimum pattern sets that bit while clearing every lower bit.
The maximum positive pattern has a leading zero followed by n−1 ones, whose combined value is 2^(n−1)−1.
It is a leading 1 followed by zeros in every remaining bit position.
It is a leading 0 followed by ones in every remaining bit position.
Yes. The same range formula works for any fixed bit width.
It contains 2^n unique bit patterns and therefore 2^n representable signed values.
Yes. It uses JavaScript BigInt for exact integer arithmetic up to the supported 1024-bit input width.

Scroll to Top