Twos Complement Calculator
Convert any integer to two's complement binary (and back) for 4, 8, 16, 32, or 64-bit widths.
Use the Twos Complement Calculator
Conversion Mode
Enter a value and click Convert
Two's Complement Binary
Other Representations
Signed Decimal
Hexadecimal
Octal
Step-by-Step Derivation
Copied!
Summary
Two's complement is the standard way modern CPUs represent signed integers in binary. This calculator converts a decimal integer to its two's complement binary form for any chosen bit width, and converts two's complement binary strings back to their signed decimal value. It also shows the hexadecimal and octal equivalents and a step-by-step derivation.
How it works
- Choose a bit width: 4, 8, 16, 32, or 64 bits.
- Enter a decimal integer (or a binary string in "Binary to Decimal" mode).
- The tool checks the value fits in the selected bit width's signed range.
- For positive numbers, the result is the standard binary representation padded with leading zeros.
- For negative numbers, the tool inverts all bits of the absolute value and adds 1.
- Hex and octal equivalents are derived from the resulting bit pattern.
Use cases
- Understand how negative numbers are encoded in assembly or C.
- Verify signed integer overflow boundaries when writing embedded firmware.
- Debug bit-manipulation code by checking the expected binary pattern.
- Convert raw memory dumps to signed decimal values.
- Teach or learn computer architecture and binary arithmetic.
- Quickly compute the two's complement of a value for interview practice.
Frequently Asked Questions
Last updated: 2026-06-04 · Reviewed by Nham Vu