By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,125 Members | 1,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,125 IT Pros & Developers. It's quick & easy.

locale and numeric output

P: n/a
Hi!

My problem looks like this:

#include <iostream>
#include <locale>

int main(int argc, char* argv[])
{
std::locale::global( std::locale( "deu" ) );
std::cout.imbue( std::locale() );
std::cout << 1000.4 << " " << 0.4 << std::endl;
return 0;
}

This is MS VC++ 7.1 here (explains the "deu" locale, it's the same with
"german").

Output is:

1,000.4 0,4

Now, this is confusing! I really expected

1.000,4 0,4

Any suggestions?

Regards,
M. Kluwe

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Matthias Kluwe skrev:
Hi!

My problem looks like this:

#include <iostream>
#include <locale>

int main(int argc, char* argv[])
{
std::locale::global( std::locale( "deu" ) );
std::cout.imbue( std::locale() );
std::cout << 1000.4 << " " << 0.4 << std::endl;
return 0;
}

This is MS VC++ 7.1 here (explains the "deu" locale, it's the same with
"german").

Output is:

1,000.4 0,4

Now, this is confusing! I really expected

1.000,4 0,4
Shouldn't you at least be expecting 1.000,4 0,4 ?

I don't know what sort of function imbue() is
but it seems it just formats the numbers
as if it were financial calculations.
Any suggestions?

Regards,
M. Kluwe

Jul 23 '05 #2

P: n/a
> Matthias Kluwe skrev:
[...] Now, this is confusing! I really expected 1.000,4 0,4
Shouldn't you at least be expecting 1.000,4 0,4 ?
Didn't I say that?
I don't know what sort of function imbue() is
but it seems it just formats the numbers
as if it were financial calculations.


What sort of? Member of ios, I think. Should imbue (!) the stream with
the given locale ...

Anyway, I just checked with gcc 3.3.5 with the expected result, so
maybe I should consult a VC++ specific group.

Regards,
Matthias

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.