Omniadisce

Computational physics 4.6: Numbers a computer can't store exactly

Lesson Beginner

Join free to take this lesson

Anyone can look around, but taking a lesson needs a free account. With one, your answers are checked step by step and your progress is saved, so you can stop and pick up where you left off on any device.

10 steps ยท about 20 min

By the end you can

  • Say why 0.1 + 0.2 isn't exactly 0.3 on a computer
  • Read a tiny number such as 5.55e-17
  • Explain why 0.1 + 0.2 == 0.3 is False
  • Compare two decimal numbers with abs(a - b) < 1e-9

Who it is for: Anyone who has done lesson 4.5.

The steps

  1. 0.1 + 0.2
  2. Why: a computer counts in twos
  3. How big is the error?
  4. Is it equal?
  5. Compare with a tolerance
  6. Is x 0.3?
  7. The times of linspace
  8. Find the time
  9. Adding 0.1 ten times
  10. Advice for a friend

Discussion 0 comments

Log in to join the discussion.

× Enlarged view