Advanced Topic 41 of 51 Math for Computing
Floating Point Error
Rounding and precision limits in machine arithmetic.
How it works
Floating-point numbers store a limited number of significant digits, so most real numbers are rounded, and arithmetic results are rounded again. Errors include rounding error bounded by machine epsilon, about 1e-16 for doubles, cancellation when subtracting nearly equal numbers loses significant digits, absorption when adding a tiny number to a huge one has no effect, overflow and underflow and non-associativity: (a + b) + c may differ from a + (b + c). Special values include infinity and NaN.
Where it is used
Scientific computing, financial calculations, graphics, game physics and machine learning must manage floating-point error, using techniques like Kahan summation, compensated algorithms and higher precision.
Common pitfall
Comparing floats for equality, accumulating many small values in single precision and using floats for currency cause bugs. Results can differ across compilers, hardware and optimization settings. Use relative and absolute tolerances for comparisons, sort or pairwise sum data, rearrange formulas to avoid cancellation and use decimal types for money.
Where it fits in the course
Floating Point Error is topic 41 of 51 in Math for Computing, rated Advanced. It follows Numerical Methods. The next topic is Root Finding.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Math for Computing quiz.
- Explore the Binary & Two's Complement visualizer: Flip bits and watch the number change.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Math for Computing quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Floating Point Error?
Where do people use Floating Point Error?
What is the most common mistake with Floating Point Error?
What should I learn before this topic?
How can I practice it?
Is Floating Point Error hard to learn?
How long does it take to learn Floating Point Error?
Which topics are related to Floating Point Error?
What should I study after Floating Point Error?
Related topics
- Numerical Methods (Math for Computing)
- Root Finding (Math for Computing)
- Simplex Method (Math for Computing)
- Numerical Integration (Math for Computing)
- Floating Point Representation (Computer Architecture & Logic)
- Error Detection and Correction (Computer Networks)
- Error Handling (Programming Fundamentals)