NSTimer or double to int cast (Bug?)
NSTimer or double to int cast (Bug?)
- Subject: NSTimer or double to int cast (Bug?)
- From: Marco Binder <email@hidden>
- Date: Thu, 9 Jan 2003 19:50:37 +0100
I found something very strange. I made a simple countdown app on my G4,
using a simple NSTimer (countDown), firing every 1.0 seconds. However:
double interval = [countDown timeInterval];
NSLog(@"time interval: %f, rounded: %d",interval,(int)interval);
the above code gives, correctly on my G4:
2003-01-09 16:55:56.750 CountDownApp[697] time interval: 1.000000,
rounded: 1
But when running the app on an iMac G3 or my iBook (G3 obviously), it
results in:
2003-01-09 16:58:20.832 CountDownApp[697] time interval: 1.000000,
rounded: 0
Wich in the end resulted in my seconds-counter not being decreased (
seconds = seconds-(int)[countDown timeInterval];)
My solution is to use (int)round([countDown timeInterval]); instead.
Doesn anyone know what is going on here? It seems to me like a bug, at
least a rather severe inconsistency.
marco
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.