Skip to content
BetterDL

Signed number

Also called: signed, signed integer, signed binary

A number format that can represent negative values as well as positive ones, usually by giving the most significant bit a sign role.

A signed number can be negative. Hardware has no minus sign, only bits, so a signed format is a rule saying which bit patterns stand for negative values.

The formats you'll meet:

  • Two's complement: the MSB has weight −2ⁿ⁻¹. Used by essentially every modern processor.
  • Sign-magnitude: the MSB is a sign flag and the other bits are the size. Easy to read, awkward for arithmetic.
  • One's complement: negatives are bitwise inversions. Historical, with two zeros.

In all three, the MSB is the sign bit: 1 means negative.

"Signed" describes how you interpret bits, not the bits themselves. 11110000 is 240 as an unsigned number and −16 as a two's complement number. A program has to know which it means, which is why languages have separate signed and unsigned types and processors keep separate flags for each (see signed vs unsigned).

The price of signing: half the patterns go to negatives, so the largest positive value is roughly half of what the same bits reach unsigned.

1
−128
1
64
1
32
1
16
0
8
0
4
0
2
0
1

Worked example

Example

What signing costs in 8 bits

The same 256 patterns, shared out three ways.

  1. 1.

    Unsigned: 0 to 255.

  2. 2.

    Two's complement: −128 to 127. Half the patterns are negative.

  3. 3.

    Sign-magnitude: −127 to 127, because +0 and −0 use two patterns for one value.

Common mistakes

  • Asking whether a pattern "is" signed. Ask how it's being read.

  • Assuming every signed format is two's complement. Check whether a question uses sign-magnitude.

  • Expecting signed and unsigned formats to share the same largest value.

Practice Signed number

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Signed number is taught in Number Systems.