Piotr B. wrote:[color=blue]
>
> Hello,
>
> I use MingGW g++ 3.2.3 on Windows 2000/AMD Athlon XP.
> I tried to output a "long double" variable using stdio printf().
> I've tried various %formats (%llf, %Lf etc.), but none of them worked...
>
> The same source compiled with Borland C++Builder 5.0
> works for %Lf format.
>
> How to get the same results with MinGW g++ ?
>
>
>
> #include <stdio.h>
> int main()
> {
> long double x = 1.5;
> printf("%llf %llf %llf %llf\n", x, x, x, x);
> printf("%Lf %Lf %Lf %Lf\n", x, x, x, x);
> printf ("%Le %LE %Lf %LF %Lg %LG\n", x, x, x, x, x, x);
> return 0;
>
> /*
> MinGW g++ 3.2.3 output (all wrong):
> -2.000000 0.000000 0.000000 -2.000000
> -2.000000 0.000000 0.000000 -2.000000
> -2.000000e+000 8.094277E-320 0.000000 -2 8.09428E-320
>
> Borland C++Builder 5.0 output (%Lf works):
> -2.000000 0.000000 0.000000 -2.000000
> 1.500000 1.500000 1.500000 1.500000
> 1.500000e+00 1.500000E+00 1.500000 %LF %Lg %LG
> */
> }[/color]
MINGW is broken regarding long double. I had reported this myself some
time ago, and in summary here is what is going on:
In Windows world double and long double is the same. However in MINGW
long double is larger than double, however (I do not know more
specifics) it can print only the long double of MS Windows, that is the
double.
They are using an MS library or something.
You have two options. Either stick to double which is the same in
Windows world, or use DJGPP which is another GCC port (but creates
32-bit DOS executables).
Or use some other compiler.
--
Ioannis Vranos
http://www23.brinkster.com/noicys