Excel not adding decimal numbers correctly

microsoft excelworksheet-function

If I have a cell (A1) with a constant of -1.1 and then 11 subsequent cells referring to the first A1, and then to each previous one consecutively, after 11 cells, I'm expecting an answer of 0. Instead I get one of 0.000000000000000038777878078145.

Example:

formula     || result
A1=-1.1     || -1.1
A2=A1+0.1   || -1
A3=A2+0.1   || -0.9
A4=A3+0.1   || -0.8
A5=A4+0.1   || -0.7
A6=A5+0.1   || -0.6
A7=A6+0.1   || -0.5
A8=A7+0.1   || -0.4
A9=A8+0.1   || -0.3
A10=A9+0.1  || -0.2
A11=A10+0.1 || -0.1
A12=A11+0.1 || -1.38777878078145E-16

Best Answer

It's a problem with floating point precision and it cannot be solved. It's not just Excel that is affected by this issue - for example your browser will insist that 0.1 + 0.2 = 0.30000000000000004.

The simplest solution is to use rounding.

Related Question