Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16328
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: gives 919.8359999999999?` |
| Date | 2013-12-06 07:11 +0000 |
| Message-ID | <l7rtbp$o5b$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
On 12/5/13 at 3:05 AM, guillermo.sanchez@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`
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Re: gives 919.8359999999999?` Bill Rowe <readnews@sbcglobal.net> - 2013-12-06 07:11 +0000 Re: gives 919.8359999999999?` Richard Fateman <fateman@cs.berkeley.edu> - 2013-12-08 09:35 +0000
csiph-web