Two's Complement Calculator
Signed integers to binary/hex at 4–32 bits with the invert-and-add-one steps shown — plus range and sign-extension notes.
The beauty of two's complement: the SAME adder hardware works for signed and unsigned — only the overflow rules differ. The asymmetric range (−128 vs +127 in 8 bits) is why abs(INT_MIN) overflows in C. Watch sign EXTENSION when widening: 0xFF as int8 (−1) must become 0xFFFF as int16, not 0x00FF.
Two's Complement Calculator computes signed integers encoded to N-bit binary/hex and back, with the steps shown — free, instant and private in your browser. CS/EE students and embedded developers debugging sign bugs use it to skip the datasheet algebra: type your numbers, read the answer with the substituted formula shown step by step, and share an exact permalink of the calculation.
About Two's Complement Calculator
Two's Complement Calculator computes signed integers encoded to N-bit binary/hex and back, with the steps shown using the standard engineering relation: negative x → 2ⁿ + x (equivalently invert all bits, add 1). Worked live: −42 in 8 bits is 0b11010110 = 0xD6. The result recalculates on every keystroke, the worked-example panel shows your numbers substituted into the formula, and the Copy permalink button encodes the inputs in the URL so a colleague opens exactly your calculation. Everything runs client-side — nothing you type leaves your device.
How to use Two's Complement Calculator
- 1Enter your values — the tool starts with realistic defaults for this exact use case, so the worked example is meaningful immediately.
- 2Read the live result and the worked-example panel, which substitutes your numbers into the formula step by step.
- 3Adjust any input to compare scenarios, then use Copy result or Copy permalink to share the calculation.
Why use Two's Complement Calculator?
- ✓Implements the real formula — negative x → 2ⁿ + x (equivalently invert all bits, add 1) — with the substitution shown, not a black box
- ✓Built for CS/EE students and embedded developers debugging sign bugs
- ✓Copy result and permalink buttons — share the exact calculation in a README, forum answer or design review
- ✓100% free, no sign-up, runs entirely in your browser (works offline once loaded)
Frequently asked questions
How do you calculate two's complement?+
Signed integers encoded to N-bit binary/hex and back, with the steps shown follows negative x → 2ⁿ + x (equivalently invert all bits, add 1). For example, −42 in 8 bits is 0b11010110 = 0xD6. The calculator applies the same relation and shows the substituted arithmetic so you can verify every step.
Why does two's complement dominate over sign-magnitude?+
One adder does everything: signed and unsigned addition are the same hardware, zero is unique, and subtraction is addition of the complement. Sign-magnitude has two zeros and needs special-case logic — it survives only inside floating-point sign bits.
What is sign extension and when does it bite?+
Widening a signed value must replicate the sign bit: int8 0xFF (−1) becomes int16 0xFFFF, not 0x00FF (+255). The classic C bug is mixing signed chars with unsigned masks — printing bytes as 0xFFFFFFAB is this exact mistake.
Is the Two's Complement Calculator free and private?+
Yes — completely free with no sign-up or usage limits, and it runs entirely in your browser: the values you enter are never uploaded or stored on a server.
Related Electronics tools
PCB Trace Width Calculator (IPC-2221)
Minimum trace width for your current and temperature rise — IPC-2221 formula with copper weight, layer choice and a step-by-step worked example.
● LiveMicrostrip Impedance Calculator
Z₀ of a surface microstrip from width, height and εr (IPC-2141A), plus effective dielectric constant and propagation delay.
● LiveStripline Impedance Calculator
Characteristic impedance of an embedded stripline trace from geometry and εr — the inner-layer companion to the microstrip tool.
● Live