This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/14969] New: num_put incorrectly limits output precision
- From: "austern at apple dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Apr 2004 19:22:59 -0000
- Subject: [Bug libstdc++/14969] New: num_put incorrectly limits output precision
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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