Skip to content
100% local

Two's complement converter

Convert an integer to its two's complement bit pattern at a chosen width, or decode bits back to a number.

Input
Output

Two's complement converter

Computers store negative numbers using two's complement, not a plain minus sign — the same bit pattern means a different value depending on whether it is read as signed or unsigned. This tool converts in both directions: type one integer per line and it produces the matching two's complement bit pattern at the width you choose, or switch direction and paste bit patterns to get the signed (or unsigned) decimal value each one represents.

Pick a bit width of 8, 16, 32 or 64 — the sizes real CPUs and languages actually use for a byte, a short, an int and a long — and an output format of plain binary or hexadecimal. The signed option controls how a value is interpreted: with it on, a bit pattern is read as two's complement (so the top bit means negative) and a number must fit the signed range for that width; with it off, both directions treat the same bits as an ordinary unsigned integer. Toggling the direction swaps encoding for decoding without losing your input, so checking a round trip is one click.

Overflow is where two's complement gets confusing, so this tool makes it visible instead of hiding it: a number outside the chosen width's range still wraps the way real hardware wraps it — that wraparound is the two's complement pattern, not a bug — but the affected lines are also flagged and counted in the summary, so an unintended overflow in a batch of values doesn't slip past unnoticed. Turn that flag off if you are deliberately exploring wraparound behaviour and don't want it called out.

Paste a whole column of numbers or bit patterns at once; each line converts independently, and blank lines are preserved so the result stays lined up with the input. Everything runs locally in your browser — nothing you paste, including proprietary constants or firmware values, is ever uploaded anywhere.

FAQ

What is two's complement, in one sentence?
It's the standard way computers represent negative integers in binary: the same bits that spell a large positive number when read as unsigned spell a negative one when the top bit is read as a sign, and the two readings differ by exactly 2^width.
Why does a value get flagged as "out of range" instead of just erroring?
Wrapping is the correct two's complement behaviour for an out-of-range value, not a failure, so the tool still produces the wrapped bits. It flags the affected lines so an accidental overflow in a list of numbers is easy to spot; turn off "Flag out-of-range values" if you don't want the notice.
What does the "Signed" option change?
With it on, decoding treats the top bit as a sign (standard two's complement) and encoding requires the number to fit a signed range like -128..127 at 8-bit. With it off, the same bits are read as a plain unsigned value from 0 up to 2^width - 1.
Can I convert a whole list of numbers at once?
Yes. Paste one number (or one bit pattern, when decoding) per line and every line converts independently, in the same order, with blank lines kept in place.
Is my data uploaded anywhere?
No. Conversion runs entirely in your browser — nothing you type or paste is ever sent to a server.