From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15500 invoked by alias); 3 Oct 2002 19:36:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 15473 invoked by uid 71); 3 Oct 2002 19:36:01 -0000 Resent-Date: 3 Oct 2002 19:36:01 -0000 Resent-Message-ID: <20021003193601.15472.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, ledermg@mail.mohawkc.on.ca Resent-Reply-To: gcc-gnats@gcc.gnu.org, a.b.taylor@sympatico.ca Received: (qmail 10495 invoked by uid 61); 3 Oct 2002 19:26:19 -0000 Message-Id: <20021003192619.10494.qmail@sources.redhat.com> Date: Thu, 03 Oct 2002 12:36:00 -0000 From: a.b.taylor@sympatico.ca Reply-To: a.b.taylor@sympatico.ca To: gcc-gnats@gcc.gnu.org Cc: ledermg@mail.mohawkc.on.ca X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify: ledermg@mail.mohawkc.on.ca Subject: libstdc++/8135: fixed and scientfic output with different precisions is inconsistent with standard X-SW-Source: 2002-10/txt/msg00129.txt.bz2 List-Id: >Number: 8135 >Category: libstdc++ >Synopsis: fixed and scientfic output with different precisions is inconsistent with standard >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu Oct 03 12:36:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Allen B. Taylor >Release: 3.2 >Organization: >Environment: DJGPP: djdev203.zip, gcc32b.zip, gpp32d.zip, bnu213b.zip. >Description: The following program generates incorrect output for floating-point output when setting various values for floatfield flags (fixed and scientific) and precision. When fixed alone or scientific alone are set, the precision is interpreted correctly (number of digits to the right of the decimal point). When both fixed and scientific are not set (the default state of cout), precision is misinterpreted (see output). Similar, but not identical output results from having both fixed and scientific set at the same time. The standard states in section 22.2.2.2 para 8 (table 58)that if neither flag is set, or if both flags are set, then floating-point numbers should print according to printf specifier %g (or %G if uppercase is set), but I think something else is happening. >How-To-Repeat: #include #include using namespace std; const double pi = 3.1415926535, sm = 0.00004321; void experiment(); int main() { experiment(); cout.setf(ios::fixed, ios::floatfield); experiment(); cout.setf(ios::scientific, ios::floatfield); 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 << endl; } >Fix: None. >Release-Note: >Audit-Trail: >Unformatted: