• 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
Re: NSDate timeIntervalSinceNow problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDate timeIntervalSinceNow problem


  • Subject: Re: NSDate timeIntervalSinceNow problem
  • From: Greg Parker <email@hidden>
  • Date: Fri, 23 Oct 2009 12:52:48 -0700

On Oct 23, 2009, at 8:50 AM, Jens Alfke wrote:
On Oct 23, 2009, at 8:46 AM, Jens Alfke wrote:
"%f" is for float. Use "%d" for doubles.

Oops, I meant "%lf" for doubles.

%f and %lf both work for both float and double.

The printf(3) man page notes:
    Modifier    a, A, e, E, f, F, g, G
    l (ell)     double (ignored, same behavior as without it)

Why? When you pass a float to a `...` function like printf(), the C language says that it gets converted ("promoted") to a double first. So printf() always sees a double even if you passed a float. (Small integer types like char and short are similarly promoted to int, but in that case the size modifier matters when the type is signed and the value is negative.)


-- Greg Parker email@hidden Runtime Wrangler


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSDate timeIntervalSinceNow problem (From: PCWiz <email@hidden>)
 >Re: NSDate timeIntervalSinceNow problem (From: "Stephen J. Butler" <email@hidden>)
 >Re: NSDate timeIntervalSinceNow problem (From: Graham Cox <email@hidden>)
 >Re: NSDate timeIntervalSinceNow problem (From: PCWiz <email@hidden>)
 >Re: NSDate timeIntervalSinceNow problem (From: Jens Alfke <email@hidden>)
 >Re: NSDate timeIntervalSinceNow problem (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: IKImageBrowserView Dragging outside
  • Next by Date: Avoid Compiler Warning regarding IB 3.2
  • Previous by thread: Re: NSDate timeIntervalSinceNow problem
  • Next by thread: Re: NSDate timeIntervalSinceNow problem
  • Index(es):
    • Date
    • Thread