Ch 5 · Negative Numbers — Two's Complement · Theory

Topic 5 of 14 in Data Representation — How Computers Store Everything as Numbers — 3 lessons.

The Problem with Minus Signs

Computers only store 0s and 1s — there is no separate minus sign. So how do we store −5? The agreed answer is two's complement: the most-significant bit becomes a sign column with a negative value.

Making a Negative Number

To write −20 in 8-bit two's complement:

Range and a Common Trap

An 8-bit two's-complement number holds −128 to +127 (not −128 to +128). There is one more negative value than positive because zero uses up a "positive" slot.

All topics in Theory Data-representation

  1. Why Computers Use Binary
  2. Counting in Binary
  3. Hexadecimal — Shorthand for Binary
  4. Binary Addition & Overflow
  5. Negative Numbers — Two's Complement
  6. Logical Binary Shifts
  7. Representing Text
  8. Representing Images
  9. Representing Sound
  10. Storage Units & Compression
  11. Floating-Point Numbers (A Level)
  12. More Number Representations
  13. File Organisation & Access (A Level)
  14. Check Your Understanding