This code:
#include <stdio.h>
int main(void)
{
printf("%a\n", 1.0);
printf("%x\n", 93);
}
outputs:
0x1p+0
5d
Why not 0x5d
?
Does someone know the rationale?
Note: this question is not exactly the same since it is about %#x
.
Reason of the question: for %x
cannot always "feed it back to C in initializer":
$ cat t324.c
#include <stdio.h>
int main(void)
{
printf(X);
}
$ gcc t324.c -DX="\"double x = %a;\", 10.0" && ./a.exe | gcc -xc - -c
<nothing>
$ gcc t324.c -DX="\"int x = %x;\", 10" && ./a.exe | gcc -xc - -c
<stdin>:1:9: error: ‘a’ undeclared here (not in a function)