public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/9151: [3.2/3.3/3.4 regression] std::setprecision limited to 16 digits when outputting a double to a stream
@ 2003-01-06 11:03 paolo
  0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2003-01-06 11:03 UTC (permalink / raw)
  To: andrew, gcc-bugs, gcc-prs, nobody, paolo

Synopsis: [3.2/3.3/3.4 regression] std::setprecision limited to 16 digits when outputting a double to a stream

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Mon Jan  6 03:03:13 2003
Responsible-Changed-Why:
    Working on it.
State-Changed-From-To: open->analyzed
State-Changed-By: paolo
State-Changed-When: Mon Jan  6 03:03:13 2003
State-Changed-Why:
    Confirmed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9151


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: libstdc++/9151: [3.2/3.3/3.4 regression] std::setprecision limited to 16 digits when outputting a double to a stream
@ 2003-01-06 15:53 paolo
  0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2003-01-06 15:53 UTC (permalink / raw)
  To: andrew, gcc-bugs, gcc-prs, paolo

Synopsis: [3.2/3.3/3.4 regression] std::setprecision limited to 16 digits when outputting a double to a stream

State-Changed-From-To: analyzed->closed
State-Changed-By: paolo
State-Changed-When: Mon Jan  6 07:53:47 2003
State-Changed-Why:
    Fixed for 3.2.2 and 3.3.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9151


^ permalink raw reply	[flat|nested] 3+ messages in thread

* libstdc++/9151: [3.2/3.3/3.4 regression] std::setprecision limited to 16 digits when outputting a double to a stream
@ 2003-01-03  6:16 andrew
  0 siblings, 0 replies; 3+ messages in thread
From: andrew @ 2003-01-03  6:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9151
>Category:       libstdc++
>Synopsis:       [3.2/3.3/3.4 regression] std::setprecision limited to 16 digits when outputting a double to a stream
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 02 22:16:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Andrew Pollard
>Release:        gcc-3.2 and above
>Organization:
>Environment:
i686-pc-linux-gnu on a PIII system
>Description:
[ Re: http://gcc.gnu.org/ml/libstdc++/2002-12/msg00064.html ]

libstdc++-v3 in gcc-3.2 and above limits the precision in a std::setprecision() call to 16 digits when outputting a double to a stream. This (for some reason) causes the output of std::numeric_limits<double>::min() to be such that when you read the string value back into a double, the double is not the same as the double output.

For some reason double::min() requires 18 digits for this to
work.

A test case follows...

double.c:
----------------------------
#include <limits>
#include <sstream>
#include <iomanip>

int
main()
{
    int    prec = std::numeric_limits<double>::digits10+3;
    double val1 = std::numeric_limits<double>::min();
    double val2 = 0.0;

    std::stringstream ss1;
    ss1 << std::setprecision(prec) << val1 << std::ends;
    std::stringstream ss2(ss1.str());
    ss2 >> val2;

    return (val1 == val2);
}
--------------------------------

% g++30 double.cxx; ./a.out; echo $?
1
% g++32 double.cxx; ./a.out; echo $?
0
% g++33 double.cxx; ./a.out; echo $?
0
% g++34 double.cxx; ./a.out; echo $?
0
>How-To-Repeat:

>Fix:
The 'obvious fix' is to change the +1 to a +3 in include/bits/locale_facets.tcc:_M_convert_float line 627
[seems to be the same code in 3.2/3.3 and 3.4]

Quite why this needs 18 digits here, I haven't got a clue though.
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-01-06 15:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-06 11:03 libstdc++/9151: [3.2/3.3/3.4 regression] std::setprecision limited to 16 digits when outputting a double to a stream paolo
  -- strict thread matches above, loose matches on Subject: below --
2003-01-06 15:53 paolo
2003-01-03  6:16 andrew

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).