O
Opus the Penguin
This may be in a FAQ somewhere, but I'm not even sure how to search for
it. It's not really about significant digits, but the subject line's
got to say something. If anyone's interested, see if you can reproduce
the following results in Excel. I'm using Excel 2003 SP3.
1. In cell A1, type:
=1.1-0.9
I should get a 0.2, and I do.
2. In cell A2, type:
0.2
(It doesn't really matter if you type the leading zero; it'll get
added. The two cells should look identical, right?)
3. In cell B1, type:
=IF(A1=A2,"Equal","No")
This should come back saying "Equal" and it does.
4. In cell B2, type:
=IF(A1-A2=0,"Equal","No")
Since A1 and A2 are equal, subtracting them should get me zero. Yet
this comes back with a "No" in my Excel 2003 SP3.
Weird, huh? What gives?
I tried formatting the cells to 30 decimal places to see if there was
anything lurking in the insignificant digits. Nothing.
But, wait! Try this step:
5. In cell B3, type
=A1-0.3
That gives me -0.10, just as I'd expect. But format THAT cell to 30
decimal places and ... I get -0.099999999999999900000000000000. (You
can also see this by copying the cell and pasting the value only into
another cell. Then it will still say -0.10, but the formula bar will
tell you a different story.
As I say, what gives? This happens on all three of my computers that
have Excel 2003 SP3. I don't have any other versions to test. None of
the computers is brand new, but none are old Pentium 4s or anything.
The one I discovered the error on is less than two years old--a Dell
Optiplex GX745.
it. It's not really about significant digits, but the subject line's
got to say something. If anyone's interested, see if you can reproduce
the following results in Excel. I'm using Excel 2003 SP3.
1. In cell A1, type:
=1.1-0.9
I should get a 0.2, and I do.
2. In cell A2, type:
0.2
(It doesn't really matter if you type the leading zero; it'll get
added. The two cells should look identical, right?)
3. In cell B1, type:
=IF(A1=A2,"Equal","No")
This should come back saying "Equal" and it does.
4. In cell B2, type:
=IF(A1-A2=0,"Equal","No")
Since A1 and A2 are equal, subtracting them should get me zero. Yet
this comes back with a "No" in my Excel 2003 SP3.
Weird, huh? What gives?
I tried formatting the cells to 30 decimal places to see if there was
anything lurking in the insignificant digits. Nothing.
But, wait! Try this step:
5. In cell B3, type
=A1-0.3
That gives me -0.10, just as I'd expect. But format THAT cell to 30
decimal places and ... I get -0.099999999999999900000000000000. (You
can also see this by copying the cell and pasting the value only into
another cell. Then it will still say -0.10, but the formula bar will
tell you a different story.
As I say, what gives? This happens on all three of my computers that
have Excel 2003 SP3. I don't have any other versions to test. None of
the computers is brand new, but none are old Pentium 4s or anything.
The one I discovered the error on is less than two years old--a Dell
Optiplex GX745.