Mathematics I / Variables, Types, and Expressions
Practice question · True or false

Because a float stores only finitely many digits, two computations that are mathematically equal can produce values that differ slightly.

Hints
  1. Each intermediate result is rounded to the nearest representable value.
  2. Rounding errors from different routes need not cancel.
Show the answer

True

Why

True. Every stored float is rounded, and two different routes to the same mathematical value round at different places, so the tiny errors differ. That is precisely why exact equality tests on floats are unreliable.

Read the lesson: Variables, Types, and Expressions →

Practise Variables, Types, and Expressions

The app has 4 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.

More questions on Variables, Types, and Expressions