views:

261

answers:

5

How can I do that? What's the format specifier?

For example, I have:

long long veryLong = // assume value here
NSLog(@"%f", veryLong); // of course wrong...
+2  A: 

Try using %lli.

I'd have written simply %lli, but SO doesn't like short answers.

Rhythmic Fistman
Next time, you could use `<pre><code>%lli</code></pre>`
Georg
That goes towards my word count? Cool.
Rhythmic Fistman
Not usually cool (excessive hyperlinkage can thwart one's natural propensity toward verbosity), but cool in this case. ;)
Peter Hosey
+5  A: 

The String Format Specifiers section of the String Programming Guide for Cocoa is a great bookmark for your browser ... ;-)

Joshua Nozzi
+3  A: 

You need %qi, my friend.

Mark Suman
A: 

Yet another way though unnecessary if it's a plain old type and not already an NSNumber, if you convert this to an NSNumber or something similar then the included format method will automatically do the right thing if you just use %@.

Nimrod
+2  A: 
long long veryLong = // assume value here
NSLog(@"My long long is: %lld", veryLong); // now it's right
David Kanarek