On 28 September 2012 07:31, Pawel Aleksander Fedorynski <[email protected]> wrote: > On Fri, Sep 28, 2012 at 1:01 AM, Mateusz Loskot <[email protected]> wrote: >> On 27 September 2012 17:19, Vadim Zeitlin <[email protected]> wrote: >> > On Thu, 27 Sep 2012 19:50:08 +0400 Sergei Nikulov >> > <[email protected]> wrote: >> > >> > SN> So it can be MSVS2010 issue. >> > >> > Microsoft CRT has known issues with converting NaNs and infinities >> > to/from >> > strings and behaves differently from most (all?) Unix libc >> > implementations, >> > so I'm almost sure it is indeed MSVS-specific. However you can't change >> > its >> > CRT behaviour so this still needs to be worked around somehow. >> >> Textual representation of NaN value and features like strtod("NAN") >> are specified by C99 standard. Visual C++ does not implement C99. > > > But that's not what we're talking about here. What Sergei reported is that > MSVC sees a very long number (longer than a double can store) in > std::istringstream's underlying buffer, tries to read a double from this > stream, and instead of putting the stream in failed state puts inf in the > double. I.e., something like > > double x; > std::istringstream > iss("99999999999999999999999912222222222222222222222222223" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333" > "9999999999999999999999991222222222222222222222222222333333333333"); > iss >> x; > > With gcc iss.fail() is true after this operation, with MSVC apparently it > contains infinity.
Aleksander, I missed the point, indeed. That is interesting issue, and I also recall it's MSVC-specific. I always assumed it is related to C99 behaviour of strtod-like parsing. Curiosity. I may try to ask MS folks about that. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net ------------------------------------------------------------------------------ Got visibility? Most devs has no idea what their production app looks like. Find out how fast your code is with AppDynamics Lite. http://ad.doubleclick.net/clk;262219671;13503038;y? http://info.appdynamics.com/FreeJavaPerformanceDownload.html _______________________________________________ Soci-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/soci-users
