✦ Spark of Why

Free tool · runs in your browser

Two's complement calculator with steps (4 to 64 bits)

Signed integers in computers use two's complement. Type a decimal number or a bit pattern and choose the width.

bits
+

Questions

Why invert and add one?
It makes the bit patterns for x and −x add up to 2^n, which overflows to 0 — so ordinary binary addition also works for negative numbers.

When does overflow happen?
When two numbers with the same sign produce a result with the other sign — the true result is outside the range.

Is anything uploaded?
No, everything runs in your browser.

All tools and explanations