View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Jerry W. Lewis Jerry W. Lewis is offline
external usenet poster
 
Posts: 837
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

"Scott" wrote:

All the above formulas work, but what is wrong with mine? Try mine for
yourself; there are no extra fractions past two decimal places.


=(A1-B1-C1)
evaluates to -9.09494701772928E-13, which is why your If function fails.

David's answer makes sense, but it is simple math that = zero. Why can't
Excel do that? It seems to be a flaw to me.


As David has pointed out, all of your decimal fractions are non-terminating
binary fractions that cannot be exactly represented in binary (just as 1/3
cannot be exactly represented as a decimal fraction). Excel (and almost all
other computer software) uses IEEE double precision binary representation of
floating point numbers. The decimal equivalents of the binary approximations
to your numbers are

11813.2099999999991268850862979888916015625
5375.649999999999636202119290828704833984375
6437.5600000000004001776687800884246826171875

Do the math yourself; Excel's answer is the correct result given the
unavoidable approximations to your initial numbers.

The reason that rounding solves the problem should be obvious. The
alternate proposal of =IF(A1-SUM(B1:C1)=0,"OK","OFF") is a less robust
solution that will not work for all numbers.

Jerry