Until now this has not been a problem but from about today I ran into a strange issue that does not happen all the time, but rarely, I'd say one time out of 50, or even less.
I'm comparing two CGFloat:s like this:
const CGFloat MYFIRSTFLOAT = /* get the first value */
const CGFloat THESECONDFLOAT = /* get the second value */
if (MYFIRSTFLOAT < THESECONDFLOAT) {
// do something
}
else {
// Do something else
}
As you can see I'm not comparing using ==
or anything because these are floats... (like, it shouldn't be related to How dangerous is it to compare floating point values? now should it)
And the problem I'm having is I run into the occasion where the two values are exact, but the comparison evaluates to YES. In my case both of the values are "8926.5" - this value I got from LLDB. Is there a good explanation to this??? (I'm thinking that LLDB rounds off both values, meaning that they could be other values really - but why then would this also happen at runtime?)
This kind of puts me off cause I can't just see the problem... well, I'm thinking of forcing the floats to int only for this comparison, and it might be ok for my use this time, but I feel that this problem had better be totally understood :-P