public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/14220] New: num_put::do_put() undesired float/double behavior
@ 2004-02-20  1:38 sadfate at yahoo dot com
  2004-02-20 12:11 ` [Bug libstdc++/14220] " pcarlini at suse dot de
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: sadfate at yahoo dot com @ 2004-02-20  1:38 UTC (permalink / raw)
  To: gcc-bugs

When a float or double is streamed to output in fixed-point format, rounding up
occurs well before the precision specified by the stream.

5.55555555e-17, when streamed to a stream with the scientific flag set and a
precision of 25 will print 5.55555555[#'s-up-to-20]e-17.  When streamed with the
fixed flag set, it will print out 0.0000000000000000560000000.  If the number is
especially small (e-20+), it will print out as all zeroes.

I looked at the code in 3.2.3 and 3.4 versions of g++, and saw that it was
because the max_digits is being set from the numeric_limits<double>::digits10
field.  The precision is then set to be less than or equal to the max_digits. 
So on my platform, where digits10 is 16 (+2), the precision will get set to 18,
max.  That works fine for scientific values, but I would argue that if I ask a
stream for 25 places of precision, and put a float/double into it that should be
represented by 0.0000000000000000555555555, that I would see that value, not a
rounded version.

My understanding is that the numeric_limits<double>::digits10 value for a
float/double amounts to the significant digits if it were in scientific
notation.  If that is the case, then the max_digits for fixed number would be
digits10 + the number of preceding zeroes, which is probably max_exponent10.

This was seen on Solaris 8 and Irix 6.5.22.

-- 
           Summary: num_put::do_put() undesired float/double behavior
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sadfate at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14220


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

end of thread, other threads:[~2004-07-29 22:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-20  1:38 [Bug libstdc++/14220] New: num_put::do_put() undesired float/double behavior sadfate at yahoo dot com
2004-02-20 12:11 ` [Bug libstdc++/14220] " pcarlini at suse dot de
2004-02-20 17:08 ` pcarlini at suse dot de
2004-02-22 15:00 ` cvs-commit at gcc dot gnu dot org
2004-02-22 15:33 ` cvs-commit at gcc dot gnu dot org
2004-02-22 17:57 ` cvs-commit at gcc dot gnu dot org
2004-03-24  8:53 ` pcarlini at suse dot de
2004-04-15 20:14 ` pcarlini at suse dot de
2004-04-30 18:24 ` cvs-commit at gcc dot gnu dot org
2004-06-12 22:57 ` [Bug libstdc++/14220] [3.5 only] " mmitchel at gcc dot gnu dot org
2004-06-13  8:34 ` [Bug libstdc++/14220] [3.5] " pcarlini at suse dot de
2004-06-18 23:55 ` mmitchel at gcc dot gnu dot org
2004-07-29 22:11 ` cvs-commit at gcc dot gnu dot org
2004-07-29 22:14 ` pcarlini at suse dot de

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).