Slashdot Mirror


MinGW and MSVCRT Conflict Causes Floating-Point Value Corruption

jones_supa writes: If you are working on a C++ program where you need very accurate floating point numbers, you might have decided to use long double data type for the extra precision. After a few calculations, you happen to print your number. To your shock, instead of the number being 123.456789, it is printed out as -6.518427 × 10^264 (or 2.745563 depending on your computer). This is actually a bug in some versions of MinGW g++ 4.8.1 (MinGW is a port of GNU programming tools for Windows). Microsoft's C++ runtime library reserves 80 bits for double and long double. When MinGW uses the Microsoft DLL to print out the value, the number is interpreted as using only 64 bits. This discrepancy causes garbage results to be output.

1 of 98 comments (clear)

  1. Re:the 80 bit issue is well known by gl4ss · · Score: 3, Funny

    "I don't mix GCC with msvcrt so I am not sure how old / new this is." Why anybody WOULD mix the two and ever expect anything to work, ever, is kind of beyond me. I guess if you have a week to go through everything line-by-line and your project is manageably small enough to do so.

    yeah why would you link a windows application against windows ui dll's? maybe to display something using them..

    --
    world was created 5 seconds before this post as it is.