Skip navigation.
 
mlNSTimer or double to int cast (Bug?)
FROM : Marco Binder
DATE : Thu Jan 09 19:50:37 2003

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_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlNSTimer or double to int cast (Bug?) Marco Binder Jan 9, 19:50
mlRe: NSTimer or double to int cast (Bug?) Cameron Hayne Jan 10, 08:55
mlRe: NSTimer or double to int cast (Bug?) Marco Binder Jan 10, 14:05
mlRe: NSTimer or double to int cast (Bug?) Cameron Hayne Jan 10, 16:07
mlRe: NSTimer or double to int cast (Bug?) Marco Binder Jan 10, 16:29
mlRe: NSTimer or double to int cast (Bug?) Chris Ridd Jan 10, 16:49
mlRe: NSTimer or double to int cast (Bug?) Dave Camp Jan 10, 17:39
mlRe: NSTimer or double to int cast (Bug?) Marco Binder Jan 10, 17:51
mlRe: NSTimer or double to int cast (Bug?) Chris Kane Jan 10, 21:03
mlRe: NSTimer or double to int cast (Bug?) Dietmar Planitzer Jan 10, 21:05
mlRe: Re: NSTimer or double to int cast (Bug?) Cameron Hayne Jan 10, 21:25
mlRe: NSTimer or double to int cast (Bug?) Chris Ridd Jan 11, 09:47
mlRe: NSTimer or double to int cast (Bug?) Marco Binder Jan 11, 15:35
mlRe: NSTimer or double to int cast (Bug?) Chris Ridd Jan 11, 16:33
mlRe: NSTimer or double to int cast (Bug?) Marco Binder Jan 11, 17:49
mlRe: NSTimer or double to int cast (Bug?) Dietmar Planitzer Jan 11, 23:21