Thread overview | |||||
---|---|---|---|---|---|
|
December 14, 2009 "%a" formatting differences | ||||
---|---|---|---|---|
| ||||
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 |
December 14, 2009 Re: "%a" formatting differences | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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.
|
December 14, 2009 Re: "%a" formatting differences | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | 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
|
Copyright © 1999-2021 by the D Language Foundation