View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
wabbleknee wabbleknee is offline
external usenet poster
 
Posts: 31
Default Baffeling IF statement

Thanks joeu2004. I suspected that it was a rounding error, but dismissed it
because it was only happening with 0:50. Surely, there has to be others
that are not an exact match from a pure number standpoint, that would not
give a response as "TRUE" or "YES" in my case. Will try the Round function,
but stand puzzled on how to implement that. My existing formula was severly
reduced in an attempt to solve the problem. As the original formula was
implemented, I always check the "input" for a blank and if so write a blank
and in addition, sometimes the hours run across the midnight hour. i.e
23:59 to 0:10 . So my formula looks like this: C7 time is when the clock
starts, c8 thru c15 are time elapse (goal measurements) from the starting
point. =IF(C9="","",MOD(C9-$C$7,1)) then I am checking the result against
a maximum value (<=goal) to see if we met that goal. So looking at my
original question, was the 0:50 minute goal met, Yes, however the status
column said NO. Tried several times to implement the ROUND function into
the original formula =IF(C9="","",MOD(C9-$C$7,1)) . Thanks for your
response, sounds like you been there before :o)

"joeu2004" wrote in message
...

On May 10, 1:18 pm, "wabbleknee" wrote:
a1=9:00

[....]
c1= [...] =B1-A1

[....]
e1 formula =IF(c1=D1,"Yes","No")

[....]
b1=9:50, c1 showes 0:50
D1=0:50
e1 is now = NO it should be YES


This is not as uncommon as you might think. For example,
=IF(10.1-10=0.1,TRUE) returns FALSE(!).

And sometimes =IF(A1=B1,TRUE) returns TRUE, but =IF(A1-B1=0,TRUE)
returns FALSE. Or =IF(A1+B1-C1=A1-C1+B1,TRUE) returns FALSE(!).

First, you need to understand that Excel time is stored as a fraction
of a day. So 1 hour is 1/24, 1 minute is 1/1440, and 1 second is
1/86400.

Second, most non-integer numbers cannot be represented exactly because
Excel (and most applications) usually uses binary floating-point to
represent numbers and perform arithmetic.

These little inaccuracies sometimes magnify noticable after performing
arithmetic.

One remedy is to always explicitly round any arithmetic that involes
non-integer numbers. Usually, we use ROUND (or some variant of it).
For time expressions, you might also use TEXT.

And it is best to round the cell that performs the computation. So
instead of fixing E1, fix C1 as follows:

=ROUND((B1-A1)*1440,0)/1440

=--TEXT(B1-A1,"hh:mm")

formatted as Time or a Custom format like [h]:mm.

The double-negative converts the text result to numeric.