Prev: Passing structure of pointers as an argument
Next: Is compiling CUDA-based S-functions, the using Real-Time Workshop Embedded Coder possible?
From: matlab user on 24 Mar 2010 20:46 Hello, I have a simple question: Where does the error -8.8818e-016 come from? thank you in advance. >> aa=[-0.6033 0.4265 0.9790 -0.1211]; >> bb=[10 10 10 10 ]; >> cc=aa*bb' cc = 6.8110 >> cc - 6.811 ans = -8.8818e-016
From: Nicholas Kinar on 24 Mar 2010 21:01 On 24/03/2010 6:46 PM, matlab user wrote: > Hello, I have a simple question: > > Where does the error -8.8818e-016 come from? thank you in advance. > >>> aa=[-0.6033 0.4265 0.9790 -0.1211]; >>> bb=[10 10 10 10 ]; >>> cc=aa*bb' > > cc = > 6.8110 > >>> cc - 6.811 > > ans = > -8.8818e-016 Perhaps this error can be explained most succinctly by the inability of a computer to perform exact mathematics on floating point numbers. Here's some more information. http://en.wikipedia.org/wiki/Floating_point_numbers That's also the reason why you need to be careful when comparing floating point numbers: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm Nicholas
From: Matt Fig on 24 Mar 2010 21:23
http://matlabwiki.mathworks.com/MATLAB_FAQ#Why_is_0.3-0.2-0.1_not_equal_to_zero_.28or_similar.29.3F |