From fbe99d42146bc0d10a475a0c08877bf89426ebe0 Mon Sep 17 00:00:00 2001 From: Mario Antonioletti Date: Wed, 8 May 2013 08:18:37 +0100 Subject: [PATCH] Added an example of finite arithmetic problems. --- testing/RealWorld.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/testing/RealWorld.md b/testing/RealWorld.md index d9bbce7..16dd063 100755 --- a/testing/RealWorld.md +++ b/testing/RealWorld.md @@ -14,7 +14,17 @@ The [Muon Ion Cooling Experiment](http://www.mice.iit.edu/) (MICE) have a large ## When 1 + 1 = 2.0000001 -Computers don't do floating point arithmetic too well. This can make simple tests for the equality of two floating point values problematic due to imprecision in the values being compared. +Computers don't do floating point arithmetic too well. For example: + + $ python + >>> tot = 0.0 + >>> for i in range(1,100): + >>>... tot = tot + 0.01 # Expect answer to be 1.0 + >>>... + >>> print tot + >>> 0.99 + +This can make simple tests for the equality of two floating point values problematic due to imprecision in the values being compared. $ python >>> expected = 1 + 1 -- 2.26.2