View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default Baffeling IF statement

PS....

On May 10, 2:32*pm, I wrote:
This is not as uncommon as you might think.

[....]
sometimes =IF(A1=B1,TRUE) returns TRUE, but
=IF(A1-B1=0,TRUE) returns FALSE.


And this is what is misleading you into think 9:49 and 9:51 work.
IF(C1=D1,"yes","no") returns "yes", but IF(C1-D1=0,"yes","no") returns
"no".

This demonstrates that C1 is not actually identical to D1. The
difference is so small that we cannot see it even if we format C1 and
D1 as Number with 16 decimal places in this case (i.e. to display 15
significant digits).

The reason for the different results of the two IF expressions is the
dubious heuristic poorly described under the misleading title "Example
When a Value Reaches Zero" at http://support.microsoft.com/kb/78113.

In short, Excel sometimes forces a result to be zero or a comparison
to be equal if Excel considers the result to be "close enough" to
zero. (MS does not explain what is considered "close enough".)

KB 78113 also attempts to explain the binary floating-point form and
its consequences. The explanation is not very good, IMHO. And it is
incorrect in several details. But it might give you some useful
insight.