Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3516

Re: Bug 1+4/10

From Peter Breitfeld <phbrf@t-online.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Bug 1+4/10
Date 2011-07-06 11:06 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iv1fjv$vs$1@smc.vnet.net> (permalink)
References <iv1acv$sk7$1@smc.vnet.net>

Show all headers | View raw


"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

Back to comp.soft-sys.math.mathematica | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Bug  1+4/10 "slawek" <slawek@host.pl> - 2011-07-06 09:37 +0000
  Re: Bug  1+4/10 Peter Breitfeld <phbrf@t-online.de> - 2011-07-06 11:06 +0000
    Re: Bug  1+4/10 "slawek" <slawek@host.pl> - 2011-07-07 11:41 +0000
  Re: Bug  1+4/10 "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-07-07 11:27 +0000
    Re: Bug  1+4/10 "slawek" <human@site.pl> - 2011-07-08 08:52 +0000
    Re: Bug  1+4/10 "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-07-09 11:41 +0000
  Re: Bug 1+4/10 Daniel Lichtblau <danl@wolfram.com> - 2011-07-07 11:35 +0000

csiph-web