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.
- Concepts
- Questions
- Sort and link
- The numbers
- Scenarios
- 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:
floatanddoublein C and Java, and Python'sfloat(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)`Falsepuis0.9999999999999999Truepuis1.0Falsepuis1.0Truepuis0.9999999999999999
Show the answer
Falsepuis0.99999999999999990.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
printshows 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.