Schraalhans said:
Hi,
printf's format specifier %X only prints values of up to 8 hex digits.
I am using GCC on Gentoo Linux. (How do I find which GCC version I have?)
gcc questions, like all implementation-specific questions, belong in an
implementation-specific newsgroup, but only after checking the supplied
documentation. As it happens, your documentation adequately explains
the switches available in invoking gcc. Check it.
Is it possible to print values as hex up to 15 or 16 hex digits? If not,
a workaround would be appreciated also.
#include <stdio.h>
#include <limits.h>
int main(void)
{
unsigned char uc = UCHAR_MAX;
unsigned short us = USHRT_MAX;
unsigned int ui = UINT_MAX;
unsigned long ul = ULONG_MAX;
unsigned long long ull = ULLONG_MAX;
puts("[output, specific values are implementation-dependent.]");
printf("UCHAR_MAX, %u (decimal), %#o (octal), %#x (hex)\n",
uc, uc, uc);
printf("USHRT_MAX, %u (decimal), %#o (octal), %#x (hex)\n",
us, us, us);
printf("UINT_MAX, %u (decimal), %#o (octal),\n %#x (hex)\n",
ui, ui, ui);
printf("ULONG_MAX, %lu (decimal), %#lo (octal),\n %#lx (hex)\n",
ul, ul, ul);
printf
("ULLONG_MAX, %llu (decimal),\n %#llo (octal),\n %#llx (hex)\n",
ull, ull, ull);
puts("[end of output]");
return 0;
}
[output, specific values are implementation-dependent.]
UCHAR_MAX, 255 (decimal), 0377 (octal), 0xff (hex)
USHRT_MAX, 65535 (decimal), 0177777 (octal), 0xffff (hex)
UINT_MAX, 4294967295 (decimal), 037777777777 (octal),
0xffffffff (hex)
ULONG_MAX, 4294967295 (decimal), 037777777777 (octal),
0xffffffff (hex)
ULLONG_MAX, 18446744073709551615 (decimal),
01777777777777777777777 (octal),
0xffffffffffffffff (hex)
[end of output]
Bite me.