Pelles C forum

C language => Beginner questions => Topic started by: jj2007 on September 09, 2016, 02:59:41 PM

Title: Printing long double
Post by: jj2007 on September 09, 2016, 02:59:41 PM
Code: [Select]
  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?

Title: Re: Printing long double
Post by: TimoVJL on September 09, 2016, 05:48:34 PM
gcc use msvcrt.dll ?
with gcc internal function
Code: [Select]
__mingw_printf("This is a long double:\t%.9Lf\n", ld);
Title: Re: Printing long double
Post by: jj2007 on September 09, 2016, 05:56:44 PM
Code: [Select]
This is a long double with msvcrt printf:       0.000000000
This is a long double with mingw printf:        1234567890.123456717

Nice find, Timo!
Title: Re: Printing long double
Post by: TimoVJL on September 09, 2016, 06:13:06 PM
-D__USE_MINGW_ANSI_STDIO useful too