Strange hex formatting in NSString

Posted by pseudopeach on Stack Overflow See other posts from Stack Overflow or by pseudopeach
Published on 2011-01-09T17:48:14Z Indexed on 2011/01/09 17:54 UTC
Read the original article Hit count: 176

Filed under:
|
|

Try this:

unsigned long long int N; = 23229877463LL;
NSString* s = [NSString stringWithFormat:@"dec:%qi, hex:%qX",N,N];

NSLog(@"output: %@",s);

output: dec:23229877460, hex:689BCCD400000005

What's up with the 00000005??? In mySQL, hex(23229877460) = 5689BCCD4. Also, every other language seems to do this correctly. A 16 digit long hex is like 4 gazillion (16^16), right?

How can I get objective-c to format hex numbers that other languages can understand?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about nsstring