|
From: | Chuck Swiger |
Subject: | Re: Bug with numeric calculation |
Date: | Thu, 17 Aug 2006 11:07:17 -0700 |
On Aug 17, 2006, at 1:10 AM, Dr. C. Griewatsch wrote:
echo 1.0 1.1 | gawk '{print 0.1+$1-$2}' 0 echo 1.1 1.2 | gawk '{print 0.1+$1-$2}' 2.22045e-16The same error can be reproduced with gawk 3.1.5 on the same machine, orwith gawk 3.1.0 on Solaris 5.8, and with gawk 3.1.4 on Suse 9.3.
Floating point numbers are represented at finite-precision binary values, which is discussed in considerable detail here:
http://en.wikipedia.org/wiki/Floating_point#Problems_with_floating- point
-- -Chuck
[Prev in Thread] | Current Thread | [Next in Thread] |