Two's Complement Calculator

See how computers store signed integers: convert a number to its two’s complement bit pattern, or decode a pattern back to a number.

Direction

Pattern 11111011.

8-bit two's complement1111 1011
HexFB
Range for 8 bits−128 to 127

Step by step

  1. Write 5 in binary with 8 bits: 0000 0101
  2. Flip every bit (one's complement): 1111 1010
  3. Add 1: 1111 1011

How two’s complement works

  1. Write the positive value in binary with the chosen number of bits: 5 = 0000 0101.
  2. Flip every bit: 1111 1010.
  3. Add 1: 1111 1011 = −5.

The leftmost bit is the sign: 1 means negative. An 8-bit signed byte holds −128 to 127.

Frequently asked questions

What is -5 in 8-bit two's complement?

11111011.

What is the range of an 8-bit signed integer?

−128 to 127.

Why do computers use two's complement?

Addition and subtraction work the same way for positive and negative numbers.