Skip to content
Calcumatix

Two's Complement Calculator

Turn a signed whole number into two's complement binary, or read a fixed-width binary pattern as decimal, at 4, 8, 16, or 32 bits.

Result

11111011

-5 in 8-bit two's complement is 11111011

Quick Answer

A 2s complement calculator turns signed whole numbers into fixed-width binary and back. For a negative value n, add n to 2^bits. Then write the sum in binary. With 8 bits, 256 + (−5) = 251, so −5 becomes 11111011. The chosen width sets the range and padding.

Understanding 2s Complement: What Signed Bits Show

A 2s complement calculator reads a fixed row of bits as a signed whole number. The left bit sets the sign rule. A 0 starts zero or a positive value. A 1 starts a negative value. Bit width sets the range. This tool uses 4, 8, 16, or 32 bits. From decimal to binary, the tool adds lead zeros to fill the row. From binary to decimal, the tool reads signed place weights. The standard name is “two's complement” or “2s complement.” The typo “2th complement calculator” points to the same task. Students meet this form in digital logic and computer systems. One zero serves both signs. The fixed width lets add and subtract use one set of bit rules.

The 2s Complement Formula And How Signed Values Work

Two's complement representations use fixed bit widths to represent signed integers. Negative values are offset by 2^bits, while non-negative values are written as standard binary.

  • Two's complement = binary(2^b + n) for negative n at b bits.
  • Two's complement = binary(n), padded to b bits for non-negative n.
  • Decimal value = unsigned value − 2^b if the first bit is 1.
  • Decimal value = unsigned value if the first bit is 0.

b: the chosen bit width.

n: the signed decimal whole number.

2^b: the number of distinct patterns at b bits.

2s Complement Steps: Enter Values, Convert, Then Check

Inputs

  • Direction: choose decimal to binary or binary to decimal.
  • Bit width: select 4, 8, 16, or 32 bits.
  • Decimal value: enter a signed whole number in range.
  • Binary value: enter the exact number of bits.

Steps

  1. Choose the conversion direction and bit width.
  2. Enter the signed decimal value or binary row.
  3. Calculate and read the converted value.
  4. Check the lead bit and the selected range.

2s Complement Example With Every Binary Step Shown

Decimal value n is −5, bit width b is 8.

  1. Find the full 8-bit count: 2^8 = 256.
  2. Add the negative value: 256 + (−5) = 251.
  3. Write 251 in binary: 251 = 128 + 64 + 32 + 16 + 8 + 2 + 1.
  4. Mark those powers of two to get the bit pattern: 11111011.

−5 in 8-bit two's complement is 11111011. No rounding is used because both values are exact integers.

When A 2s Complement Calculator Gives The Right Answer

Use this calculator for signed whole numbers at a fixed bit width. Pick the width first. Then enter the value. Use another format for unsigned data, binary fractions, floating-point data, sign-magnitude, or one's complement.

For nearby mathematical, base conversion, and computer logic tools, see the math calculators hub and look up concepts in the glossary.

Assumptions

  • Each input is a whole number or bit row.
  • The width is 4, 8, 16, or 32 bits.
  • Positive values use standard binary with zero padding.
  • Negative values use two's complement.
  • Binary input has no spaces, prefix, or decimal point.
  • Every conversion is exact.

Limitations

  • Values outside the selected signed range cannot be represented.
  • The calculator does not perform binary arithmetic or flag arithmetic overflow.
  • Binary fractions and floating-point formats are outside the tool's scope.
  • A binary pattern has no signed meaning until a bit width and convention are known.

In Practice

Leading bits are easy to drop. A short row can change meaning when width changes. Keep all 8 bits for an 8-bit value. Do not trim a run of lead zeros or ones.

Related Guides

2s Complement Calculator Questions With Clear Answers

Why Does A Leading 1 Mean A Negative Value?

A leading 1 gives the left bit a negative place weight in two's complement. At b bits, the left place weighs −2^(b − 1). All other places keep positive powers of two, so their values add to or offset that sign weight.

What Range Fits In An 8-Bit Signed Integer?

An 8-bit signed whole number has a range from −128 through 127. The low bound is −2^(8 − 1) = −128. The high bound is 2^(8 − 1) − 1 = 127. Those bounds use all 256 bit patterns once.

Is 2s Complement The Same As Invert And Add One?

Invert and add one is another way to form a negative fixed-width bit row. The rule 2^b + n gives the same row for a negative decimal value n. The two paths match when the bit width stays the same.

Why Must The Bit Width Be Chosen First?

The chosen bit width sets both the sign place and the signed range. For example, 1111 means −1 at 4 bits. The row 00001111 means 15 at 8 bits. The same digits can mean a new value at a new width.

Sources

Last updated: . Reviewed for accuracy against the formula shown above.