Two's complement is the standard binary encoding scheme used by modern computer hardware to represent signed negative and positive integers.
Two's Complement is the mathematical operation and standard binary numeral encoding system used by modern computer microprocessors (x86, ARM, RISC-V) to represent and calculate signed integers.
In an $N$-bit two's complement system, the most significant bit (MSB) serves as the sign bit: 0 denotes a non-negative integer, and 1 denotes a negative integer. The fundamental advantage of two's complement over older representations (like Sign-Magnitude or One's Complement) is that arithmetic addition, subtraction, and multiplication operations are identical for signed and unsigned integers at the hardware circuit level.
You can inspect and toggle signed two's complement bits across 8, 16, 32, and 64-bit widths using our interactive Number Base Converter.
| Bit Width | Data Type Equivalent | Minimum Signed Value ($-2^{N-1}$) | Maximum Signed Value ($+2^{N-1}-1$) | Total Distinct States ($2^N$) |
|---|---|---|---|---|
| 8-bit | int8, i8, signed char |
$-128$ (0x80) |
$+127$ (0x7F) |
$256$ |
| 16-bit | int16, i16, short |
$-32,768$ (0x8000) |
$+32,767$ (0x7FFF) |
$65,536$ |
| 32-bit | int32, i32, int |
$-2,147,483,648$ (0x80000000) |
$+2,147,483,647$ (0x7FFFFFFF) |
$4,294,967,296$ |
| 64-bit | int64, i64, long long |
$-9,223,372,036,854,775,808$ | $+9,223,372,036,854,775,807$ | $1.844 \times 10^{19}$ |
To compute the negative equivalent $-X$ of a positive integer $X$ in an $N$-bit register:
1 to the inverted result.$$\text{Two's Complement}(-X) = (\sim X) + 1$$
1. Decimal +18 in 8-bit binary: 00010010
2. Invert all bits (NOT): 11101101
3. Add 1: + 00000001
-------------------------------------------
Binary Result for -18: 11101110 (Hex: 0xEE)
To verify: $$11101110_2 = -128 + 64 + 32 + 8 + 4 + 2 = -18$$
+0 = 00000000) and negative zero (-0 = 11111111), Two's Complement has exactly one unique zero (00000000), preventing ambiguity in branch conditions and equality checks.For interactive exploration of bit grids, IEEE 754 floating-point numbers, and radix translations, visit our Number Base Converter.
Free, browser-based utilities to test, generate, and inspect Two's Complement Binary Representation payloads directly.