digitalmars.D.learn - "%a" formatting differences
- bearophile <bearophileHUGS lycos.com> Dec 14 2009
- BCS <none anon.com> Dec 14 2009
- bearophile <bearophileHUGS lycos.com> Dec 14 2009
Do you know what's causing the difference in the outouts?
void main() {
double d1 = 3.14159;
printf("%a\n", d1);
writefln("%a\n", d1);
}
Outputs:
0x1.921f9f01b866ep+1
0xc.90fcf80dc337p-2
A printf in C code compiled with GCC prints the same as the printf here.
Bye,
bearophile
Dec 14 2009
Hello bearophile,Do you know what's causing the difference in the outouts? void main() { double d1 = 3.14159; printf("%a\n", d1); writefln("%a\n", d1); } Outputs: 0x1.921f9f01b866ep+1 0xc.90fcf80dc337p-2 A printf in C code compiled with GCC prints the same as the printf here. Bye, bearophile
Just a guess: D is correctly using double and C is assuming float? Try running it with d1 as a float to check.
Dec 14 2009
BCS:Just a guess: D is correctly using double and C is assuming float? Try running it with d1 as a float to check.
I have run the code again with the last D1 compiler, and now writeln is giving the same result as printf. So probably it was a writefln bug that's already fixed. Sorry for the useless noise -.- Bye, bearophile
Dec 14 2009








bearophile <bearophileHUGS lycos.com>