0-0 Wai Wai ^-^ wrote:
> It doesn't really matter how the number is displayed after, say, 15 decimal
> points.
> But what I want is it can still be calculated without being affected by this
> minor mistake.
Calling it a "mistake" suggests that you still do not understand. It is
an inevitable consequence of finite precision mathematics. Suppose you
were doing decimal math with 4-figure precision. Then (4+1/3)-(4+2/3)
would be
4.333-4.667 = -0.334
There is no mistake, but the result is numerically different from the
representation of 1/3 = 0.3333 in this system.
You are presumably aware that numbers like 1/3, 1/7, 1/11, etc. cannot
be exactly represented in decimal, and so you are not surprised when
numbers like these have to be approximated. The only additional
surprise here is that numbers like 1/5 are also non-terminating binary
fractions, with the result that most finite decimal fractions (including
..03, .07, .1, .15, and .97) can only be approximated. When you do math
with approximate inputs, you should not be surprised when the result is
also an approximation. It is not an "error", "mistake", "imperfect
conversion", etc. it is just the nature of the beast.
Converting to BCD as joeu2004 suggested would not eliminate the problem,
as my decimal example illustrated. It would just confine the problem
(finite precision approximation to numbers that can only be exactly
represented in infinite precision) to numbers where we more readily
recognize what has happened. BCD is rarely done in computers, because
it is relatively wasteful and slow, which seems a steep price to pay for
a "solution" that doesn't fully solve the problem.
Extended precision packages like xlPrecision also do not solve the
problem, they just push it farther out (though they do have their uses).
The only way to completely solve the problem is to do symbolic math
http://en.wikipedia.org/wiki/Compute...lgebra_systems
But the performance penalty from that option would be totally
unacceptable for large spreadsheets.
> Just like the countif function. It can't calculate well due to the small
> difference of 0.00....005
> Any workaround is appreciated.
If you are unwilling to standardize the approximations (using ROUND() on
the calculations or setting the Precision as Displayed option), then you
need to do comparisons that are robust to approximations. Examples
would include IF(ROUND(C4,2)=0.07,... or IF(ABS(C4-0.07)<0.005,...
For summarizing a range, this would generally require array formulas.
Jerry
Bookmarks