Twos Complement Calculator

Convert any integer to two's complement binary (and back) for 4, 8, 16, 32, or 64-bit widths.

Conversion Mode

Enter a value and click Convert

Copied!

Summary

Convert any integer to two's complement binary (and back) for 4, 8, 16, 32, or 64-bit widths.

How it works

  1. Choose a bit width: 4, 8, 16, 32, or 64 bits.
  2. Enter a decimal integer (or a binary string in "Binary to Decimal" mode).
  3. The tool checks the value fits in the selected bit width's signed range.
  4. For positive numbers, the result is the standard binary representation padded with leading zeros.
  5. For negative numbers, the tool inverts all bits of the absolute value and adds 1.
  6. 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-10 · Reviewed by Nham Vu