Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
I found strange error in matlab R2013a calculation using0 'floor'
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Use variable c1=0.011. c1 is multiplied by 10 until c1=11. Then use floor(c1) and get value 10
c1=0.011;
c1=c1*10;
c1=c1*10;
c1=c1*10;
floor (c1)
ans =
10
Then use variable c1=0.0011. c1 is multiplied by 10 until c1=11. Then use floor(c1) and get value 11
c1=0.0011;
c1=c1*10;
c1=c1*10;
c1=c1*10;
c1=c1*10;
floor (c1)
ans =
11
Then use variable c1=0.11. c1 is multipled by 10 until c1=11. Then use floor(c1) and get value 11
c1=0.11;
c1=c1*10;
c1=c1*10;
floor (c1)
ans =
11
WHY the first result differ from second and third?
0 Commenti
Risposte (1)
A Jenkins
il 25 Ott 2013
Because floating point math is a strange thing.
Try setting
format long
and then rerun your above calculations. (Remove the semicolons so you can the results.)
Also look at the FAQ and the links included there: http://www.mathworks.com/matlabcentral/answers/57444-faq-why-is-0-3-0-2-0-1-not-equal-to-zero
0 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!