[Bug libstdc++/14969] New: num_put incorrectly limits output precision
austern at apple dot com
gcc-bugzilla@gcc.gnu.org
Thu Apr 15 19:39:00 GMT 2004
Consider the following test case:
#include <iostream>
#include <iomanip>
int main()
{
double pi = 3.14159;
std::cout << std::setprecision(40) << pi << std::endl;
}
Compiling and running this program gives the output:
3.1415899999999999 We've got 16 digits after the
decimal point, even though we've requested 40.
There's code in locale_facets.tcc that limits the precision
if it's "out of range". I don't see any justification for
doing that either in clause 22.2.2.2.2 of the C++
standard, which defines the behavior in terms of printf,
or in clause 7.19.6.1 of the C standard, which describes
printf itself. (FWIW the C standard does say that there is
an implementation defined upper limit for printf
conversions, but it is required to be at least 4095.)
--
Summary: num_put incorrectly limits output precision
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: austern at apple dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: powerpc-apple-darwin7.3.0
GCC host triplet: powerpc-apple-darwin7.3.0
GCC target triplet: powerpc-apple-darwin7.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14969
More information about the Gcc-bugs
mailing list