I'n obj-c I have a timer fire every .1 seconds and increment a double value (seconds) by .1 So it should basically keep time counting up by tenths of a sec. When it fires it checks some if else statements to see if (seconds) is equal to 3, 9, 33 etc. but these are never triggered. I suppose it is because of the way doubles are represented in bits thats the decimal is an approximation and never actually a whole number.
How can I fix this so my statements are triggered?
-(void)timeSeconds:(NSTimer*)theTimer{
seconds = seconds+0.1;
NSLog(@"%f", seconds);
if (seconds==3.0) {
[player pause];
[secondsTimer invalidate];
}
else if (seconds==9){
[player pause];
[secondsTimer invalidate];
}