locale and numeric output

M

Matthias Kluwe

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
 
P

Pelle Beckman

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

Matthias Kluwe

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,155
Latest member
JuliW73391
Top