Bug 20909 - incorrect floating point format
Summary: incorrect floating point format
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: 4.0.0
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-08 19:40 UTC by Ray Lischner
Modified: 2005-04-25 09:52 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2005-04-08 21:00:56


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ray Lischner 2005-04-08 19:40:52 UTC
In some locales, certain floating point numbers are printed incorrectly. (I
think the problem lies with numbers with one significant digits, in scientific
format, with a thousands separator and thousands grouping.)

For example:

#include <iostream>
#include <locale>
#include <ostream>

int main()
{
  std::wcout.imbue(std::locale("en_US"));
  std::wcout << 2e10 << '\n';
}

Prints "2e,+10".
Comment 1 Paolo Carlini 2005-04-08 21:00:56 UTC
Yes, this is actually a very long standing bug, which we hoped didn't trigger
in common situations (because the fix probably is rather ugly :(
Ok, let's finally work on it. Thanks for your report.
Comment 2 GCC Commits 2005-04-09 00:09:11 UTC
Subject: Bug 20909

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	paolo@gcc.gnu.org	2005-04-09 00:08:59

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/bits: locale_facets.tcc 
Added files:
	libstdc++-v3/testsuite/22_locale/num_put/put/char: 20909.cc 
	libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t: 20909.cc 

Log message:
	2005-04-08  Paolo Carlini  <pcarlini@suse.de>
	
	PR libstdc++/20909
	* include/bits/locale_facets.tcc (num_put<>::_M_insert_float):
	Don't even try to group numbers like 2e20, i.e., no decimal
	point, scientific notation.
	* testsuite/22_locale/num_put/put/char/20909.cc: New.
	* testsuite/22_locale/num_put/put/wchar_t/20909.cc: Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.2968&r2=1.2969
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_facets.tcc.diff?cvsroot=gcc&r1=1.211&r2=1.212
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/num_put/put/char/20909.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20909.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 3 GCC Commits 2005-04-09 00:15:14 UTC
Subject: Bug 20909

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	paolo@gcc.gnu.org	2005-04-09 00:14:59

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/bits: locale_facets.tcc 
Added files:
	libstdc++-v3/testsuite/22_locale/num_put/put/char: 20909.cc 
	libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t: 20909.cc 

Log message:
	2005-04-08  Paolo Carlini  <pcarlini@suse.de>
	
	PR libstdc++/20909
	* include/bits/locale_facets.tcc (num_put<>::_M_insert_float):
	Don't even try to group numbers like 2e20, i.e., no decimal
	point, scientific notation.
	* testsuite/22_locale/num_put/put/char/20909.cc: New.
	* testsuite/22_locale/num_put/put/wchar_t/20909.cc: Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.2917.2.21&r2=1.2917.2.22
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_facets.tcc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.211&r2=1.211.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/num_put/put/char/20909.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/20909.cc.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 4 Paolo Carlini 2005-04-25 09:51:38 UTC
Fixed for 4.0.0.
Comment 5 Paolo Carlini 2005-04-25 09:52:31 UTC
.