MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Zero does not Equal Zero

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31281] Re: Zero does not Equal Zero
  • From: Adam Smith<adam.smith at hillsdale.edu>
  • Date: Fri, 26 Oct 2001 04:28:27 -0400 (EDT)
  • References: <9qokvl$mu2$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

The problem is that you specified a non-integer value for the number of digits
of precision "21.35".  As shown below, if you set it equal to an integer things
work out as expected.  I don't know what SetPrecision does intenally when it is
a non-integer, but I agree that something strange happens.

In[1]:=
x=SetPrecision[1234567890123456789012, 21.35];
y=x-6/5;
{x-y, x-y\[Equal]0}

Out[3]=
{0.,False}

In[4]:=
x=SetPrecision[1234567890123456789012, 21];
y=x-6/5;
{x-y, x-y\[Equal]0}

Out[6]=
{0.,True}




In article <9qokvl$mu2$1 at smc.vnet.net>, Ersek, Ted R says...
>
>Hello Group,
>
>I am using Mathematica Version 4.1.0.0 under Windows 98, but I suspect it
>makes no difference what platform is used. 
>
>The following demonstrates an inconsistency with arbitrary precision
>arithmetic. The problem is that the criteria for deciding what numbers are
>displayed as zero is different from the criteria for deciding if a number
>equals zero.
>
>
>In[1]:=
>  x=SetPrecision[1234567890123456789012, 21.35];
>  y=x-6/5;
>  {x-y, x-y==0}
>
>Out[3]=
>  {0., False}
>
>
>----------
>For what it's worth, the next line shows that the precision of (x-y) is
>(0.0366) almost zero.
>
>In[4]=
>  InputForm[x-y]
>
>Out[4]=
>  1.2`0.0366
>
>-----------
>Regards, 
>  Ted Ersek
>  Check Mathematica Tips, Tricks at
>  http://www.verbeia.com/mathematica/tips/Tricks.html
>
>

Adam Smith
Dept. of Physics
Hillsdale College
adam.smith at hillsdale.edu


  • Prev by Date: FW: Carriage Return oddity in Mathematica (follow-up)
  • Next by Date: Re: Export of Cells in Bitmap
  • Previous by thread: Zero does not Equal Zero
  • Next by thread: Re: Re: Zero does not Equal Zero