Re: Bug 1+4/10
- To: mathgroup at smc.vnet.net
- Subject: [mg120036] Re: Bug 1+4/10
- From: "Oleksandr Rasputinov" <oleksandr_rasputinov at hmamail.com>
- Date: Thu, 7 Jul 2011 07:27:09 -0400 (EDT)
- References: <iv1acv$sk7$1@smc.vnet.net>
On Wed, 06 Jul 2011 10:37:35 +0100, slawek <slawek at host.pl> wrote:
> Let check
>
> In[1]:= 1.4 == 1 + 4/10
> Out[1]= True
>
> In[2]:= a = SetPrecision[1.4, 30]
> Out[2]= 1.39999999999999991118215802999
>
> In[3]:= b = SetPrecision[1 + 4/10, 30]
> Out[3]= 1.40000000000000000000000000000
>
> No comment is needed.
>
> slawek
Yet:
In[4] :=
a == b
Out[4] =
False
So here we have shown that a number padded with binary zeros is generally
not equal to the same number padded with decimal zeros. I doubt anyone can
be surprised by this. However, they are still comparable in a sense:
In[5] :=
a = SetPrecision[Interval[1.4], 30]
Out[5] =
Interval[{1.39999999999999968913755310495,
1.40000000000000013322676295502}]
In[6] :=
b = SetPrecision[Interval[1 + 4/10], 30]
Out[6]=
Interval[{1.40000000000000000000000000000,
1.40000000000000000000000000000}]
In[7] :=
IntervalMemberQ[a, b]
Out[7] =
True
Proper treatment of inexact numbers requires at least some care and
attention. It is important to remember that one is operating on
distributions rather than points, so simplistic notions of arithmetic
equality are not meaningful.