Re: Bug 1+4/10

• To: mathgroup at smc.vnet.net
• Subject: [mg120034] Re: Bug 1+4/10
• From: Peter Breitfeld <phbrf at t-online.de>
• Date: Wed, 6 Jul 2011 07:05:36 -0400 (EDT)
• References: <iv1acv\$sk7\$1@smc.vnet.net>

```"slawek" 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
>
Thats documentated behaviour. In the help of Equal (Scope/Numeric
Equalities):

Approximate numbers that differ in their last seven binary digits are
considered equal. (this are about the two last decimals)

RealDigits[1.4, 2]
RealDigits[1 + 4/10, 2]

{{1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1,
0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0,
1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0}, 1}

{{1, {0, 1, 1, 0}}, 1}

or

RealDigits[1.4]
RealDigits[1 + 4/10]

{{1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1}

{{1, 4}, 1}

There is no difference in the last 2 decimals. But

1.4===1+4/10
False

SameQ returns True, if the numbers differ in the last binary digit only,
so and have the same head. (1.4 is a Real, but 1+4/10 is Rational, so
SameQ returns False)

--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

```

• Prev by Date: Re: Bug 1+4/10
• Next by Date: Re: Bug in Sum?
• Previous by thread: Re: Bug 1+4/10
• Next by thread: Re: Bug 1+4/10