LOGBOOK

HELP

1 / 48
Other keys: showSpace: good1-4: rate0: skip5: flag6: invert

Question

What are the three main encoding types used to represent information in computers?

Answer

Everything is stored as bits (each 0 or 1); the same bits mean different things depending on how they're interpreted. Integers use two encodings — unsigned and two's complement (signed).

A bit is the fundamental unit — physically just a voltage that's "low" (0) or "high" (1). On their own, bits carry no meaning; an encoding assigns meaning to a pattern.

Encoding Purpose Examples
Unsigned Non-negative integers Memory addresses, array indices, sizes
Two's complement Signed integers Positive and negative numbers

(Real numbers use a third family, floating point — base-2 scientific notation — but this topic focuses on the two integer encodings above.)

Why these integer encodings?

  • Unsigned is the simplest — just count in binary — but it can't represent negatives.
  • Two's complement handles negatives so that the same addition circuit works for both signed and unsigned values.

The key insight: Everything is bits - the pattern 11111111 is:

  • 255 if interpreted as unsigned (8-bit)
  • -1 if interpreted as two's complement
  • Part of a float if interpreted as floating point

Why this matters:

  • The bits don't "know" what they represent
  • The TYPE in your code tells the CPU how to interpret them
  • Bugs happen when you interpret bits with the wrong type!
or press any other key