Skip to content

02 Information Storage

Information Storage

Integer

image-20221202105118312

Unsigned Encodings:

image-20221202105322088

Signed Encodings (Two's complement):

image-20221202105340672

Conversion between signed and unsigned:

image-20221202105603669

WARNING: C implicitly cast signed to unsigned.

int a = -1;
unsigned int b = 0;
assert(a > b); // true, signed -1 --> unsigned 2^{32}-1 > 0

Integer Arithmetic

Overflow:

  • unsigned:

    image-20221202110344958

  • signed

    image-20221202110308769

Floating Point

image-20221202113856519

  • Normalized (most numbers):

    image-20221202114105317

    image-20221202114156987

  • Denormalized (zero, and near-zero small numbers)

    image-20221202114625408

  • Special (Infinity and NaN)

    image-20221202114331717

    image-20221202114349031