Re: Decimal math bug?
- To: mathgroup at smc.vnet.net
- Subject: [mg28816] Re: Decimal math bug?
- From: Jim Freeze <jim at freeze.org>
- Date: Mon, 14 May 2001 01:33:08 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On Sun, 13 May 2001, Murray Eisenberg wrote: > Don't think it's a program bug -- just yet one more manifestation of the > wonders of roundoff in floating point arithemetic. In Mathematica 4.1 > under Windows 2000: This 'round-off' happens under Linux. But there is a self contradiction that should be considered a bug. > (.53 + .9) - (1.43) > 2.220446049250313*^-16 .53 + .9 = 1.4300000000000002 1.43 == 1.4300000000000002 is returned as true, but 1.4300000000000002 - 1.43 is not zero. Is not this a self contradiction. I can understand this as being a round off bug if using double precision. But, since Mathematica has infinite precision, is there not some way to invoke that on this operation and not use built in double math and get the roundoff. Thanks Jim > > (where I show the InputForm of the actual output). > > Jim Freeze wrote: > > > > On Sat, 12 May 2001, Steven M. Christensen wrote: > > > > This looks like a bug. > > Can someone please explain. > > > > This is Mathematica 4.1 (just purchased) on Linux. > > > > In[88]:=(.53+.9) - (1.43) == 0 > > Out[88]:=False > > ---------^^^^^ > > > > In[89]:=(.53+.9) - (.43+1.0)== 0 > > Out[89]:=False > > ---------^^^^^ > > > > In[100]:=(.53+.9) - (.43+0.8+0.2) == 0 > > Out[100]:=False > > ----------^^^^^ > > > > In[102]:=(.53+.9) - (.43+0.8+0.1 +0.1) == 0 > > Out[102]:=True > > ----------^^^^ > > > > The above results from some strange decimal math: > > In[67]:=Range[.53,4,.9] > > Out[103]:={0.53, 1.4300000000000002, 2.33, 3.23} > > > > where sometimes 1.4300000000000002 == 1.43 and sometimes > > it doesn't. > > > > It is really disconcerting to have that trailing 2. > > > > Can someone please explain what is going on here? > > > > Thanks > > ========================================================= > > Jim Freeze > > jim at freeze.org > > --------------------------------------------------------- > > No comment at this time. > > http://www.freeze.org > > ========================================================= > > -- > Murray Eisenberg murray at math.umass.edu > Mathematics & Statistics Dept. phone 413 549-1020 (H) > Univ. of Massachusetts 413 545-2859 (W) > Amherst, MA 01003-4515 > ========================================================= Jim Freeze jim at freeze.org --------------------------------------------------------- No comment at this time. http://www.freeze.org =========================================================