I must admit that I didn't try to follow your complete code, but floats are in general a little dangerous when it comes to exactness. For example, look a this:
float x = 0.1f + 0.2f;
NSLog(@"%.20f", x); // output: "0.30000001192092895508"
This is because of the way floating points numbers are represented internally. For this reason, when you compare floating point numbers, it's recommended to not compare for an exact value, but to check if it lies within a certain range, e.g.
BOOL isEqual(float a, float b, float e)
{
return (a < b + e && a > b - e);
}
Where "e" could be small value like "0.0001f". Actually, there is a macro in Sparrow for that: SP_IS_FLOAT_EQUAL.
I hope that helps!