I'm adding up some float
s in a loop.
I expected that when i
reaches 9, the sum will be equal to 1, and NSLog(@"EXTRA: %f", sum);
will be executed. It is never executed... what is going on here?
Here is my code:
float number = 0.1;
float sum = 0;
for (int i = 0; i < 1000; i++) {
sum += number;
if (sum == 1) {
NSLog(@"EXTRA: %f", sum);
}
NSLog(@"%f", sum);
}