Signed Binary and Two's Complement Explained

Try the Binary Converter
Signed Binary and Two's Complement Explained

Unsigned vs Signed Binary

An unsigned binary number represents only zero and positive values. With 8 bits, unsigned values range from 0 to 255.

A signed binary number can represent positive and negative values. The most common method is two's complement. With 8 bits, two's complement values range from -128 to 127.

Why Two's Complement Exists

Computers need a consistent way to add and subtract positive and negative integers. Two's complement is popular because the same binary addition hardware works for both signed and unsigned values. There is no separate subtraction circuit for most cases.

Reading Positive Values

In 8-bit two's complement, values from 00000000 to 01111111 are non-negative:

Binary Decimal
00000000 0
00000001 1
00001010 10
01111111 127

If the leftmost bit is 0, read the number normally.

Reading Negative Values

If the leftmost bit is 1, the value is negative. To find its magnitude:

  1. Invert all bits.
  2. Add 1.
  3. Convert the result to decimal.
  4. Apply a negative sign.

Example:

11111011
invert -> 00000100
add 1  -> 00000101
decimal 5
result -> -5

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

Creating a Negative Number

To encode -18 in 8 bits:

+18      = 00010010
invert   = 11101101
add 1    = 11101110

So -18 is 11101110.

Range Limits

With n bits, two's complement represents:

-2^(n-1) to 2^(n-1)-1

For 8 bits, that is -128 to 127. For 16 bits, it is -32768 to 32767.

Overflow

Overflow happens when the mathematical result does not fit in the available bit width. In 8-bit signed arithmetic, 127 + 1 becomes 10000000, which represents -128. The bit pattern wraps around because only eight bits are available.

Programmers must know the integer width and signedness when reading binary data from files, networks, or embedded systems.

Two's Complement vs Text Binary

A binary text converter usually works with character bytes, not signed integers. For example, 11111011 may be interpreted as a byte value, an extended character in a legacy encoding, or -5 depending on context.

Binary has no meaning without a format. You need to know whether the bits represent text, unsigned numbers, signed numbers, floating-point values, or something else.

Frequently Asked Questions

Why is the positive range one smaller than the negative range?

Because zero takes one non-negative slot. In 8 bits, there are 256 patterns: 128 negative values, zero, and 127 positive values.

Is the leftmost bit always the sign bit?

For fixed-width two's complement integers, yes. But the same bit pattern can mean something else if the data is unsigned or not an integer.

Does JavaScript use two's complement?

JavaScript numbers are floating-point values, but bitwise operators convert operands to 32-bit signed integers using two's complement behavior.

Convert Binary Instantly

Convert between binary, text, decimal, hex, and octal with our free online tool.

Open Binary Converter