Printing long double

Started by jj2007, September 09, 2016, 02:59:41 PM

Previous topic - Next topic

jj2007

  long double ld=1234567890.1234567890;
  printf("This is a long double:\t%.9f\n", ld); // This is a long double:  1234567890.123456746


Works like a charm, as expected. Compiles fine in GCC-64, too, but there the output is 0.000000 8)
Any explanation?


TimoVJL

#1
gcc use msvcrt.dll ?
with gcc internal function__mingw_printf("This is a long double:\t%.9Lf\n", ld);
May the source be with you

jj2007

This is a long double with msvcrt printf:       0.000000000
This is a long double with mingw printf:        1234567890.123456717


Nice find, Timo!

TimoVJL

-D__USE_MINGW_ANSI_STDIO useful too
May the source be with you