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.
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.