       Re: gives 919.8359999999999?`

• To: mathgroup at smc.vnet.net
• Subject: [mg132112] Re: gives 919.8359999999999?`
• From: Richard Fateman <fateman at cs.berkeley.edu>
• Date: Sun, 8 Dec 2013 04:34:58 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-outx@smc.vnet.net
• Delivered-to: mathgroup-newsendx@smc.vnet.net
• References: <l7rtbp\$o5b\$1@smc.vnet.net>

```On 12/5/2013 11:11 PM, Bill Rowe wrote:
..... And this is characteristic is
> inherent in any modern computer.
At least when using double-precision binary floating-point arithmetic.
Which is what Mathematica happens to be using here. It doesn't always.
See below.

>
> If you want to avoid this characteristic in Mathematica, simply
> use exact arithmetic.

That may seem simple, but can lead to exponentially expensive arithmetic.
Compare Timing[Sum[1/n,{n,1,100000];]
to
Timing[Sum[1.0/n,{n,1,100000];]

As for your particular example, you could try this:

FullForm[916.53600000000000000 + 3.300000000000000000000]
which gets all the digits you expect.

David Goldberg, "What Every Computer Scientist Should Know About
Floating-Point Arithmetic".

That is
>
> In:= 916536/1000 + 33/10
>
> Out= 229959/250
>
> In:= N[%]
>
> Out= 919.836
>
> In:= FullForm[%]
>
> Out//FullForm= 919.836`
>
>

```

• Prev by Date: Mathematica Patches or Incremental Updates
• Next by Date: Re: gives 919.8359999999999?`
• Previous by thread: Re: gives 919.8359999999999?`