IEEE 754 floating point

Fractional binary and fixed point, the single-precision format (sign, exponent biased by 127, mantissa), double precision for comparison, special values, rounding errors and comparing floats.

  • 27 cards
  • 6 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. The numbers
  5. Scenarios
  6. Understand

A few cards from the deck

  • IEEE 754: what is it?

    Show the answer

    The standard that fixes how floating-point numbers are encoded in machines, their special values and the rounding rules of calculations.

    Almost all processors follow it: float and double in C and Java, and Python's float (in double precision) therefore follow the same formats and rounding rules from one machine to another.

  • What does this Python program print?

    ```python
    total = 0
    for _ in range(10):
    total += 0.1
    print(total == 1.0)
    print(total)
    `

    • False puis 0.9999999999999999
    • True puis 1.0
    • False puis 1.0
    • True puis 0.9999999999999999
    Show the answer

    False puis 0.9999999999999999

    0.1 is not exact in binary: ten additions accumulate the error and leave a gap of one last bit below 1. The comparison is therefore false, and print shows the gap.

  • A double-precision float takes … bits: 1 sign bit, … exponent bits and 52 mantissa bits.

    Show the answer

    A double-precision float takes 64 bits: 1 sign bit, 11 exponent bits and 52 mantissa bits.

    Single precision uses only 32 (1, 8 and 23). More mantissa bits give about 16 significant decimal digits instead of 7.

  • Floating-point number: what is it?

    Show the answer

    A number coded by a sign, a mantissa and an exponent, of the form ± mantissa × 2 to the power of the exponent: the exponent sets where the point lies.

    In single precision: 1 sign bit, 8 exponent bits, 23 mantissa bits. It covers very large or very small values, but with a limited number of significant digits.