[Bug libstdc++/49048] New: setprecision rounding fails in some cases
s.cecilio at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed May 18 17:49:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49048
Summary: setprecision rounding fails in some cases
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: s.cecilio@gmail.com
cecilio@pp1:~$ gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
I'm having problems with truncation. For instance, following code:
cout << "test precision 5798.12500: "
<< fixed << setprecision(2) << setfill(' ')
<< setw(10) << 5798.12500 << endl;
cout << "test precision 5798.87500: "
<< fixed << setprecision(2) << setfill(' ')
<< setw(10) << 5798.87500 << endl;
Generates inconsistent results: 5798.12 (wrong, should be 5798.13) and 5798.88
(right).
In first case rounds up and in second, down.
The same code, compiled with Microsft Visual Studio, produces the right results
in the same machine.
More information about the Gcc-bugs
mailing list