When sum the following 28 numbers in list A by Excel or Matlab with a 64-bit Windows 10 OS, a strange -7.21645E-16 was obtained. However, the result is supposed to be 0. What is the issue? Thanks for any help. A = [1 1 1 1 2 1 1 1 1 1 2 0.2 1 1 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -1 -1 -0.2]
Asked
Active
Viewed 18 times
0
-
4Floating-point error. – BigBen Oct 26 '20 at 17:05
-
Which number or numbers cause the floating-point error? – timethefirst Oct 26 '20 at 17:07
-
0.2 and -0.2.... – BigBen Oct 26 '20 at 17:07
-
How the error occurred exactly? Any explanations? – timethefirst Oct 26 '20 at 17:08
-
https://learn.microsoft.com/en-us/office/troubleshoot/excel/floating-point-arithmetic-inaccurate-result – BigBen Oct 26 '20 at 17:08
-
Look at [Floating-point arithmetic may give inaccurate results in Excel](https://learn.microsoft.com/en-us/office/troubleshoot/excel/floating-point-arithmetic-inaccurate-result) – Ron Rosenfeld Oct 26 '20 at 17:08
-
https://www.microsoft.com/en-us/microsoft-365/blog/2008/04/10/understanding-floating-point-precision-aka-why-does-excel-give-me-seemingly-wrong-answers/ – BigBen Oct 26 '20 at 17:09
-
Thanks very much! That's very useful. – timethefirst Oct 26 '20 at 17:10
-
try `0.1+0.2==0.3` :) – Ander Biguri Oct 26 '20 at 17:14