The math is exact, but the input numbers are not.
Excel follows the IEEE standard for double precision arithmetic. Part
of that standard is binary representation of numbers. None of the
numbers in B1
1 have exact finite binary representations (just as 1/3
has not exact decimal representation), so your "no more, no less" is not
true of the computer representation of those numbers).
The decimal resolution of IEEE double precision is roughly decimal 15
digits (see Help for "Excel specifications and limits", sub-topic
"Calculation specifications"). As a result, in computers your
calculation in D1 becomes
2.63000000000000???
2.62500000000000???
---------------------
0.00500000000000???
which Excel reports as
0.00499999999999989
clearly within the approximation range of the inputs. Excel has given
you the result of this calculation under the IEEE double precision
standard. Any program that gives you 0.005 is either not showing you
full precision, rounding the final result, or doing the math
differently. The most common approaches for different math are
- 10 byte extended doubles (e.g. Windows calculator, which is still
not exact, but gives more figures)
- symbolic arithmetic (e.g. Maple or Mathematica)
- binary coded decimal (e.g. XCalc combines BCD with additional
precision,
http://www.crbond.com/applications.htm). For comparable
precision BCD is slower than binary and just exchanges one set of exact
problems for a different set of exact problems.
Integers (through 2^53-1) are represented exactly in IEEE double
precision, but most decimal fractions are not. Standard programming
practice for half a century has been to test for near equality, as in
=IF(ABS(D1-0.005)<epsilon, equal, not equal)
instead of
=IF(D1=0.005, equal, not equal)
Equivalently, you could round D1 to minimize the accumulation of
discrepancies due to input approximations.
Jerry