cocoa - IF failing for double?
- by Mike
I have a set of NSTimeIntervals like this:
NSArray *mySet = [NSArray arrayWithObjects:
[NSNumber numberWithDouble: time1], //
[NSNumber numberWithDouble: time2],
[NSNumber numberWithDouble: time3],
nil];
// suppose that at this time
// time1 = 0.00000
// time2 = 18.3200
// time3 = 21.6500
at some point in my code I want to test if currentTime is greater or equal to one of the times on the array, so I do
// currentTime = 18.32 right now
for (int i=0; i<[mySet count]; i++) {
if (currentTime >= [[mySet objectAtIndex:i] doubleValue]) {
NSLog(@"%d...", i);
}
}
The output should be "1...2..."
but the output is just "1..."
when i = 1,
it is comparing 18.32 to 18.32 and failing to recognize that the value is equal or greater than the other? WTF???
How can that be?
thanks for any help.