This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/8135: fixed and scientfic output with different precisions is inconsistent with standard
- From: paolo at gcc dot gnu dot org
- To: a dot b dot taylor at sympatico dot ca, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, ledermg at mail dot mohawkc dot on dot ca, nobody at gcc dot gnu dot org, paolo at gcc dot gnu dot org
- Date: 3 Oct 2002 20:52:52 -0000
- Subject: Re: libstdc++/8135: fixed and scientfic output with different precisions is inconsistent with standard
- Reply-to: paolo at gcc dot gnu dot org, a dot b dot taylor at sympatico dot ca, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, ledermg at mail dot mohawkc dot on dot ca, nobody at gcc dot gnu dot org, paolo at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: fixed and scientfic output with different precisions is inconsistent with standard
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Thu Oct 3 13:52:51 2002
Responsible-Changed-Why:
Analyzed.
State-Changed-From-To: open->closed
State-Changed-By: paolo
State-Changed-When: Thu Oct 3 13:52:51 2002
State-Changed-Why:
Not a bug. Try the following, which compares libstdc++-v3
to the letter of the standard (22.2.2.2.2,8 and 11)
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;
const double pi = 3.1415926535,
sm = 0.00004321;
void experiment();
int main()
{
experiment();
cout.setf(ios::fixed | ios::scientific, ios::floatfield);
experiment();
return 0;
}
void experiment()
{
cout << "floatfield:";
ios::fmtflags f = cout.flags();
if (f & ios::fixed)
cout << " fixed";
if (f & ios::scientific)
cout << " scientific";
cout << endl;
for (int x = 0; x < 10; x++)
{
cout << x << ". " << setprecision(x)
<< setw(20) << pi
<< setw(20) << sm;
if (x > 0 || (cout.flags() & ios::fixed))
printf("%20.*g%20.*g\n", x, pi, x, sm);
else
printf("%20g%20g\n", pi, sm);
}
}
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8135