NO

Author Topic: Printing long double  (Read 2862 times)

Offline jj2007

  • Member
  • *
  • Posts: 536
Printing long double
« 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?


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Printing long double
« Reply #1 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);
« Last Edit: September 09, 2016, 05:50:45 PM by TimoVJL »
May the source be with you

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Printing long double
« Reply #2 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!

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Printing long double
« Reply #3 on: September 09, 2016, 06:13:06 PM »
-D__USE_MINGW_ANSI_STDIO useful too
May the source be with you