jbat100
jbat100

Reputation: 16827

What does the %qx format specifier mean

In the following obj-c function, what does the %qx format specifier mean (I would imaging the question also holds for use with printf and co.)

+(NSString*)stringForHash:(uint64_t)hash
{
    return [NSString stringWithFormat:@"%qx", hash];
}

My guess is that it means print the 64 bits in hex, as opposed to %x which would only print 32 bits. I cannot however find a good reference confirming this anywhere. What does q stand for? Can it be used in conjunction anything else than x in format specifiers?

Upvotes: 1

Views: 1632

Answers (3)

Ilanchezhian
Ilanchezhian

Reputation: 17478

You can get the format speciers from here

Upvotes: 0

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143229

q is quad, same like ll.

P.S.: printf manpage says "Don't use" ;-)

Upvotes: 4

sergio
sergio

Reputation: 69027

From Wikipedia:

it is a pre-C99 extension meaning

"q - For integer types, causes printf to expect a 64-bit (quad word) integer argument. Commonly found in BSD platforms"

Upvotes: 3

Related Questions