What printf format specifier can I use to print a 64 bit unsigned integer in hexadecimal notation across 32/64 bit and Windows/POSIX? The closest I've seen is %llX
but I'm not sure that is portable enough. Answers that ignore older compilers (e.g. Visual Studio 2010) are acceptable.
The PRIx64
macro in <inttypes.h>
is what you're looking for.
It's a string token, so you can use it as:
fprintf(stdout, "answer = %"PRIx64"\n", val);
Since you specify %llX
, you probably want uppercase; use: PRIX64
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With