As Ron and Bob have already noted, this is a known and expected phenomenon
related to the fact that your decimal fractions (indeed most decimal
fractions) must be approximated since they have no exact finite binary
representation (just as 1/3 must be approximated as a decimal fraction).
A few of points that may aid your comfort level with Excel and your
intuition in this matter:
Excel (along with almost all numerical software) represents numbers per the
IEEE 754 standard (which is designed to minimize the accumulation of rounding
errors) for double precision, and appears to use the processor's basic math
routines instead of reinventing the wheel. Thus the results in this case
(and all others that I am aware of) are comparable to what you would get from
any other IEEE double precision software package, and are completely
predictable according to the rules of that standard.
Binary conversion coupled with the limits of double precision are such that
decimal figures beyond the 15th may not be what you would otherwise expect.
Excel will not directly show you anything beyond the 15th figure, but
subtraction may reveal what is there, as you have discovered. That 15-figure
rule of thumb can be used to predict the potential level of discrepancies due
to approximation without actually doing the binary conversions. However if
you want to see what is going on at the binary level, use the VBA functions I
posted at
http://groups.google.com/group/microsoft.public.excel/msg/6efb95785d1eaff5
For most accounting purposes (an obvious exception is accumulating compound
interest over multiple periods), you can round calculation results to the
smallest unit of currency (.01 in most instances I am aware of) without
violence to the math in order to assure that discrepancies due to
approximation remain beyond the 15th figure. Excel cannot do this for you
automatically, because Excel is a general purpose tool and it would decrease
the accuracy of many other types of calculations
=((58751.04+1906.66)-(58574.36+2083.34))
will show you the difference that your IF() function was seeing. This
result is numerically correct given the initial binary conversions to IEEE
double precision.
=(58751.04+1906.66)-(58574.36+2083.34)
returns zero because Excel arbitrarily zeros the result of final
subtractions where both numbers agree to 15 decimal digits
http://support.microsoft.com/kb/78113
Excel cannot do this other than for final subtractions, because doing so
would decrease the accuracy of some calculations. This fuzz factor is
related to why
=IF(SUM(A1:A2)=SUM(B1:B2),A1,"Error")
would work in this instance even though your original formula did not. It
is less common, but possible that the accumulation of discrepancies due
approximations could accumulate to the point that SUM(A1:A2)=SUM(B1:B2) would
be false despite MS’s fuzz factor, so rounding to an intelligently chosen
level is the better approach.
Here is a naive decimal example of what happened in your calculation.
Suppose a hypothetical computer does decimal math and carries only 4
significant figures. While it is mathematically true that
10/3 = 5/3 + 5/3 = 6/3 + 4/3
that is not numerically exact in finite precision since
1.666+1.666 = 2.332
2.000+1.333 = 3.333
Jerry