Skip to content
Tezmy Tools

Two's Complement Calculator

Convert between signed numbers and two's complement bits

Smallest value
-128
Largest value
127

Hex D6

Runs in your browser. Nothing is uploaded.

About the Two's Complement Calculator

Computers store negative whole numbers in two's complement form. This calculator converts a decimal number to its two's complement bits and hex for 4, 8, 16, 32 or 64 bits, shows the smallest and largest values that fit, and reads a string of bits back to the signed decimal value. It uses exact big-number arithmetic, so 64 bits is no problem. Type a decimal number, or binary digits, and a bit width and the two's complement appears at once, with a few related figures underneath, and you can copy the result with one tap. The sums run in your browser, so nothing you enter is uploaded.

Updated October 2026

How to use the Two's Complement Calculator

  1. 1Enter a decimal number, or binary digits, and a bit width.
  2. 2Pick the units or options from the menus if the two's complement tool offers them.
  3. 3Read the two's complement in the large result box.
  4. 4Look at the extra rows for related figures.
  5. 5Press Copy result to keep the answer.

When you need the two's complement

Programmers, students of computer architecture and people debugging low-level code use it often. It makes clear why adding 1 to the biggest integer wraps round to the smallest.

A signed n-bit number covers −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1, so there is one more negative value than positive. The top bit is the sign bit.

    How the two's complement is worked out

    For a negative number, the stored value is 2ⁿ plus the number, where n is the bit width. A bit pattern with the top bit set means a negative number, equal to the pattern minus 2ⁿ. −42 in 8 bits is 256 − 42 = 214, which is 11010110 in binary or D6 in hex. Reading 11010110 as an 8-bit number gives −42 again. An 8-bit number ranges from −128 to 127.

    Every answer on this page comes from that one rule, so you can check any result by hand with a calculator. The figures shown underneath, such as other units, are conversions of the same answer.

    • Both directions
    • 4 to 64 bits
    • Shows range

    Mistakes to avoid with two's complement

    Pick the bit width first: the same bits mean different numbers at 8 and 16 bits. A number outside the range cannot be stored, and the tool says so instead of silently wrapping.

      On phone and computer

      On a phone, type into the boxes one after another and read the two's complement underneath; Copy result puts it on the clipboard for a message or a note. On a computer the inputs sit on the left and the answer on the right, so you can change one figure and watch the two's complement move. The two's complement calculator works the same on both.

        Checking your two's complement by hand

        A good habit is to test the two's complement calculator with a case you already know. −42 in 8 bits is 256 − 42 = 214, which is 11010110 in binary or D6 in hex. Reading 11010110 as an 8-bit number gives −42 again. An 8-bit number ranges from −128 to 127.

        If your own figures give a surprising answer, repeat the working yourself: For a negative number, the stored value is 2ⁿ plus the number, where n is the bit width. A bit pattern with the top bit set means a negative number, equal to the pattern minus 2ⁿ. Small differences usually come from rounding, from mixing units, or from a typing slip in one of the inputs. Signed numbers are stored in bits, so related tools help you read them. Write ones and zeros with the Binary Translator, do bit sums with the Binary and Hex Calculator, and see decimals stored as bits with the IEEE 754 Converter.

          Features

          • Pick the bit width first
          • Out-of-range numbers cannot be stored
          • The top bit is the sign
          • Clear messages when the two's complement inputs make no sense
          • Copy the result with one tap
          • Private: nothing is uploaded

          Frequently asked questions

          How do I calculate two's complement?

          For a negative number, the stored value is 2ⁿ plus the number, where n is the bit width. A bit pattern with the top bit set means a negative number, equal to the pattern minus 2ⁿ. −42 in 8 bits is 256 − 42 = 214, which is 11010110 in binary or D6 in hex. Reading 11010110 as an 8-bit number gives −42 again. An 8-bit number ranges from −128 to 127.

          What is the formula for two's complement?

          For a negative number, the stored value is 2ⁿ plus the number, where n is the bit width. A bit pattern with the top bit set means a negative number, equal to the pattern minus 2ⁿ. The two's complement calculator applies it exactly and rounds only the displayed answer to six significant figures.

          Why two's complement?

          It lets addition and subtraction use the same circuit for signed and unsigned numbers.

          What is the range of 8 bits?

          −128 to 127.

          How do I negate a number by hand?

          Flip every bit and add 1.

          Is this two's complement calculator free and private?

          Yes. It is free, needs no account and runs in your browser, so the numbers you type are not uploaded or stored.

          Related tools