Home / Guides / Two's complement and negative numbers

Two's complement and negative numbers

Computers represent negative numbers within a fixed bit width using two's complement.

Signed integers

Two's complement is the standard way to represent negatives in fixed-width integers such as 8, 16, 32 and 64 bits.

How to compute it

Flip every bit (one's complement) and add 1.

For example, -1 in 8 bits is 11111111.

Watch for overflow

Values beyond the width are truncated or flip sign. This tool's bit grid shows the value per width so you can spot overflow immediately.