c++ program produces bad results
Kevin Kofler
kevin.kofler at chello.at
Tue Feb 2 23:41:47 UTC 2010
Gene Smith wrote:
> I had tried to format with sscanf a long double with "%llf" which
> mingw32 didn't like. Changing it to "%Lf" fixes it (but still see
> warning). Found by compiling with -Wall -Wextra --pedantic. Still don't
> know why it worked OK with native g++. But still see a a couple of
> small rounding differences between the g++ native program (64bit) and
> running mingw32 program under wine (32 bit version of wine).
That's quite expected with x86 floating point. AFAIK, x86_64 uses SSE
floating-point by default, 32-bit uses x87 by default. (long double may be
always using x87 though, not sure.) The big problem with the x87
instructions is that they handle ONLY long-double-sized operations and
floats in registers are always long-double-sized, but when the floats are
stored to a "double" or "float" variable in memory, they get truncated. That
can lead to very strange behavior, especially when compiler optimization is
involved.
Kevin Kofler
More information about the mingw
mailing list