Thread: Match issue
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default Match issue

PS.... I wrote:
The problem is that numbers are not what they always appear
to be, even when they are formatted to 15 significant digits,
the most that Excel will format.

For example put =10.1-10 into A1, and put 0.1 into A2. The
formula =MATCH(A1,A2,0) returns #N/A, indicating no match.
But =MATCH(ROUND(A1,2),A2,0) returns 1 as expected.


I forgot that we __can__ see why A1's 0.1 is not the same as A2's 0.1 if we
format them to __16__ decimal places. In fact, A1 is about
0.0999999999999996, which is 15 significant digits.

Here's a better example....

Put =(1001/1E6)*1E6 into A1, and put 1001 into A2. Note: 1E6 is one way to
write 1000000 (1 million).

Then, MATCH(A1,A2,0) and MATCH(A1,A2,1) return #N/A, indicating no match.
But MATCH(ROUND(A1,2),A2,0) returns 1 as expected.

That is because the result of the computation in A1 is infinitesimally less
than 1001. It is exactly 1000.99999999999,98863131622783839702606201171875.

I use the comma after the decimal place to demarcate 15 significant digits,
the most that Excel formats. When formatted to 15 significant digits,
Excels rounds the 16th digit and beyond (9886...).

That is why Excel displays the value as if it is 1001, even when formatted
to 15 significant digits (11 decimal places, in this case).

PS: This example also demonstrates that computer arithmetic differs from
mathematical arithmetic. Of course, (1001/1E6)*1E6 is 1001 mathematically.
That is because mathematical arithmetic has unbounded precision. But
computer arithmetic has limited precision. That limitation often causes
infinitesimal differences.