0

NSLog function accepts printf format specifiers. My question is about %x specifier. Does this print hex codes as sequence on memory? Or does it have it's own printing sequence style?

unsigned int a = 0x000000FF;
NSLog(@"%x", a);

Results of above code on little or big endian processors are equal or different? And how about NSString's -initWithFormat method? Does it follows this rule equally?

eonil
  • 83,476
  • 81
  • 317
  • 516
  • Why would you expect `NSLog` to be any different in `printf` in this regard? Or are you asking about `printf` too? – jamesdlin May 14 '10 at 18:48
  • Yes, you're right. They're equal. I'm asking about printf too. I saw the linked printf document from NSLog's description, but I couldn't find any direct mention about byte order. And I don't know underlying system of C well. So I couldn't sure about it. That's the reason of why I asked this here. For conviction. – eonil May 16 '10 at 08:11

1 Answers1

3

%x always prints the most significant digits first. Doesn't matter what kind of processor it is running on.

progrmr
  • 75,956
  • 16
  • 112
  • 147