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".
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.
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
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
Fixed for 4.0.0.
.