[Date Index]
[Thread Index]
[Author Index]
Re: gives 919.8359999999999?`
*To*: mathgroup at smc.vnet.net
*Subject*: [mg132106] Re: gives 919.8359999999999?`
*From*: Bill Rowe <readnews at sbcglobal.net>
*Date*: Fri, 6 Dec 2013 02:16:46 -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
On 12/5/13 at 3:05 AM, guillermo.sanchez at hotmail.com (Guillermo
Sanchez) wrote:
>FullForm[916.536 + 3.3] gives 919.8359999999999 instead of 919.836?
Whenever you use machine precision numbers the following
sequence of events takes place. First, your input is converted
to a binary value. Then the required operation is done. Finally,
the result is converted to decimal for display.
Neither of the two values you provided above can be represented
precisely in a finite number of binary digits. So, the binary
values used to represent your input are approximations to your
input. They differ just slightly from the decimal values you
entered. And that small difference accumulates every time you do
an operation to combine values. So, the binary result converts
to a decimal just a bit more different than what it would be if
you were doing exact arithmetic. And this is characteristic is
inherent in any modern computer.
If you want to avoid this characteristic in Mathematica, simply
use exact arithmetic. That is
In[1]:= 916536/1000 + 33/10
Out[1]= 229959/250
In[2]:= N[%]
Out[2]= 919.836
In[3]:= FullForm[%]
Out[3]//FullForm= 919.836`
Prev by Date:
**Re: Manipulate and Module**
Next by Date:
**Re: Why FullForm[916.536 + 3.3] gives 919.8359999999999?`**
Previous by thread:
**Re: LocatorPane and tooltips for the locators**
Next by thread:
**Re: gives 919.8359999999999?`**
| |