[Bug libfortran/48651] DTOA float conversion issue
thenlich at users dot sourceforge.net
gcc-bugzilla@gcc.gnu.org
Sun Apr 17 18:34:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48651
--- Comment #3 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-04-17 18:34:15 UTC ---
(In reply to comment #2)
> hmm, notice the typo! i have set ldnum to 0.0 but it still is printing the
> value of dnum. What am I doing wrong.
>
> $ cat sprint.c
> #include <stdio.h>
>
> int
> main ()
> {
> float num = 0.9;
> double dnum = 0.9;
> long double ldnum = 25.6;
> printf("%50.48f\n", num);
> printf("%50.48lf, %d\n", num, sizeof(num));
> printf("%80.78f\n", dnum);
> printf("%80.78lf, %d\n", dnum, sizeof(dnum));
> printf("%80.78f\n", ldnum);
> printf("%80.78lf, %d\n", ldnum, sizeof(ldnum));
Check your format strings, use "lf" only for long double.
More information about the Gcc-bugs
mailing list