开发者

How to log an long long value with NSLog?

开发者 https://www.devze.com 2022-12-17 04:25 出处:网络
How can I do that? What\'s the format specifier? For example, I have: long long veryLong = // assume value here

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...


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


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


Try using %lli.

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


You need %qi, my friend.


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 %@.


int64 / long long int "%lld" uint_32_t "%u"

0

精彩评论

暂无评论...
验证码 换一张
取 消