Home Dashboard Directory Help
Search

I/O library incorrect rounds floating point numbers on input by cffk


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 776287
Opened: 1/10/2013 1:38:43 PM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

The C++ library for Visual Studio 11 sometimes rounds floating point
numbers incorrectly on input. For example reading

179.9999999999999855

(or 180 - 0.51*2^-45) into a double should give

179.9999999999999716

(or 180 - 2^-45) because this is the closest representable double.
However, instead it is read in as 180.0.

Visual Studio 10 does not have this bug.
Details
Sign in to post a comment.
Posted by D Allen B on 6/28/2014 at 8:29 AM
Hi Stephan: OK. Thanks for the update.
Posted by Microsoft on 6/27/2014 at 10:19 AM
> I've encountered a similar problem reading single precision numbers.

Thanks for the repro - we've discovered additional issues in this area, and we're continuing to work on them. I've added your repro to one of our active bugs, so we can verify our eventual fixes.

> What does "next major version" mean?

We're hoping to have this completely fixed in VS14, likely to be released in 2015.

> Will there be a patch for 12.0.21005.1 REL?

No, sorry. See http://blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in-vs-2013.aspx Q4 and Q5 for the reason why.

(By the way, you should install 2013 Update 2, which fixed a severe bug where temporaries in initializer lists triggered silent bad codegen.)

Stephan T. Lavavej
Senior Developer - Visual C++ Libraries
stl@microsoft.com
Posted by D Allen B on 6/27/2014 at 9:02 AM
Hi: I've encountered a similar problem reading single precision numbers. For example:
#include <iostream>
#include <iomanip>
#include <sstream>
int main ( )
{
std::stringstream ss( "76.25" );
float a;
float b = 76.25f;
ss>>a;
std::cout << std::setprecision(14) << a << std::endl;
std::cout << std::setprecision(14) << b << std::endl;
return 0;
}
yields:
76.249992370605
76.25

What does "next major version" mean? Will there be a patch for 12.0.21005.1 REL?

Thanks,
Allen
Posted by Microsoft on 4/30/2014 at 2:50 PM
We've checked in a fix for the next major version - this time we really think we've got it. We've also added a regression test to ensure that the bug doesn't reappear.

STL
Posted by cffk on 4/30/2014 at 2:42 PM
I downloaded and installed a new version of Visual Studio 2013 and I get
the same buggy output from the test program. The "About Visual Studio"
dialog reports:

    Microsoft Visual Studio Ultimate 2013
    Version 12.0.21005.1 REL

    Visual C++ 2013 06181-004-0449004-02054
    Microsoft Visual C++ 2013

Please re-open this bug report. Or, if you prefer, I'll enter a new bug
report.
Posted by Microsoft on 4/29/2014 at 12:29 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from: http://go.microsoft.com/?linkid=9832436
Posted by Microsoft on 7/17/2013 at 1:29 PM
Unfortunately, we discovered a problem with our attempted fix - it broke the parsing of "4.1" - and we had to revert it, so 2013 RTM will behave like 2012 RTM. We'll try to fix this again in the next major version.

Stephan T. Lavavej
Senior Developer - Visual C++ Libraries
stl@microsoft.com
Posted by Microsoft on 6/18/2013 at 2:49 PM
Hi again,

We've fixed this bug, and the fix will be available in VS 2013 RTM (but not Preview). Thanks again for reporting it, this one was really subtle.

Stephan T. Lavavej
Senior Developer - Visual C++ Libraries
stl@microsoft.com
Posted by Microsoft on 3/26/2013 at 12:36 AM
Hi,

Thanks for reporting this bug. I wanted to let you know what's happening with it. I'm still keeping track of it, but it's been resolved as "Deferred" because we may not have time to fix it in VC12. (Note: VC8 = VS 2005, VC9 = VS 2008, VC10 = VS 2010, VC11 = VS 2012.)

Note: Connect doesn't notify me about comments. If you have any further questions, please E-mail me.

Stephan T. Lavavej
Senior Developer - Visual C++ Libraries
stl@microsoft.com
Posted by Microsoft on 1/10/2013 at 6:39 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 1/10/2013 at 1:51 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.