• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTimer or double to int cast (Bug?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSTimer or double to int cast (Bug?)
      • From: Cameron Hayne <email@hidden>
  • Prev by Date: Re: Help File Icon in Help Viewer
  • Next by Date: Re: String Attributes
  • Previous by thread: Re: Changing the textStorage in a textView
  • Next by thread: Re: NSTimer or double to int cast (Bug?)
  • Index(es):
    • Date
    • Thread