Skip to content
๐Ÿ”ข Signed Number Representations in Binary

๐Ÿ”ข Signed Number Representations in Binary

๐Ÿง  What Are Signed Numbers?

Signed numbers allow binary systems to represent both positive and negative values. The most significant bit (MSB) typically acts as the sign bit:

  • 0 โ†’ positive
  • 1 โ†’ negative

๐Ÿ”ง Common Encoding Schemes

1๏ธโƒฃ Sign-Magnitude

+5 โ†’ 0101
โˆ’5 โ†’ 1101
  • MSB is the sign; remaining bits are magnitude
  • Two representations of zero: 0000 (+0), 1000 (โˆ’0)

2๏ธโƒฃ Oneโ€™s Complement

+5 โ†’ 0101
โˆ’5 โ†’ 1010  (bitwise NOT of +5)
  • Negative numbers are bitwise inverses of positives
  • Two zeros: 0000 (+0), 1111 (โˆ’0)
  • Requires end-around carry in addition

3๏ธโƒฃ Twoโ€™s Complement โœ… (Most Common)

+5 โ†’ 0101
โˆ’5 โ†’ 1011  (bitwise NOT of +5 โ†’ 1010, then +1)
  • Single representation of zero: 0000
  • Clean arithmetic: no special rules for subtraction
  • Range: โˆ’2โฟโปยน to 2โฟโปยน โˆ’ 1

๐Ÿงฎ Range Comparison (4-bit)

EncodingMin ValueMax ValueZero Count
Sign-Magnitudeโˆ’7+72
Oneโ€™s Complementโˆ’7+72
Twoโ€™s Complementโˆ’8+71 โœ…
Last updated on