开发者

NSString hex and decimal output?

开发者 https://www.devze.com 2023-03-22 22:16 出处:网络
NSString* s = [NSString stringWithFormat:@\"dec:%qi, hex:%qX\", 1, 1]; yields dec: 4294967297, hex:BFFFD438000...

NSString* s = [NSString stringWithFormat:@"dec:%qi, hex:%qX", 1, 1];

yields

dec: 4294967297, hex:BFFFD438000...

?开发者_StackOverflow社区?? why ???

thanks

if I use %d and %d, I get 1 and 1


q means 64-bit, so you have to pass 64-bit parameters, e.g. 1LL or 1ULL.


You can simply use NSString* s = [NSString stringWithFormat:@"dec:%i, hex:%x", 1, 1];

0

精彩评论

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