6*0.003125 - 0.018750 = 0, right? How to get the right answer?
Mostra commenti meno recenti
In Matlab >> 6*0.003125
ans =
0.018750000000000
>> 6*0.003125 - 0.01875
ans =
3.469446951953614e-18
In Mathematica
In[17]:= 6*0.003125 6*0.003125 - 0.018750
Out[17]= 0.01875
Out[18]= 3.46945*10^-18
~~~~~~~~~~~~~~~~~~~~~~~~~~~How can I get the right answer??
Risposta accettata
Più risposte (2)
Thorsten
il 15 Ott 2015
You can compare the results against the machine precision eps and regard them as equal if smaller than eps
6*0.003125 - 0.01875 < eps
1 Commento
hogeol lim
il 16 Ott 2015
Steven Lord
il 15 Ott 2015
1 voto
For a more in-depth answer to this general situation, with many references, see question 1 in the Mathematics section of the FAQ.
1 Commento
hogeol lim
il 16 Ott 2015
Categorie
Scopri di più su Mathematics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!