decimal separator

  • Thread starter Thread starter An Ony
  • Start date Start date
A

An Ony

Oh I can't believe it, my OS is in Dutch, very annoying
and now this:

double a = 0.8;
Console.WriteLine(a);

outputs: 0,8
yes! a comma!!! argh!! that's all very neat, but in order to use my output
with another program I need to have a dot and not a comma!!
Am I going to change them manually every time to a . or can I say somewhere
to use a "." and not a ","? Probably changing it in the OS's localizations,
but I'd like to leave that alone.
 
Actually, when you convert it to a string, use the ToString method and use
the one that accepts a CultureInfo. Just pick the CultureInfo for en-US
rather than using Dutch.
 
Still a bit silly that it takes the OS's region settings and not by default
the invariant, but it works I guess :/


Scott said:
I find that it makes more sense to use the InvariantCulture instead of
en-US, because the InvariantCulture won't change (it's invariant).

Ok, the US one won't change either, but you never know.

scott


Michael (michka) Kaplan said:
Actually, when you convert it to a string, use the ToString method and use
the one that accepts a CultureInfo. Just pick the CultureInfo for en-US
rather than using Dutch.


--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.


An Ony said:
Oh I can't believe it, my OS is in Dutch, very annoying
and now this:

double a = 0.8;
Console.WriteLine(a);

outputs: 0,8
yes! a comma!!! argh!! that's all very neat, but in order to use my output
with another program I need to have a dot and not a comma!!
Am I going to change them manually every time to a . or can I say somewhere
to use a "." and not a ","? Probably changing it in the OS's localizations,
but I'd like to leave that alone.
 
Actually, the normal default is to use the user's preferences. This has been
true f every version of Windows and the .NET Framework and is only
non-intuitive to developers who do not take into account the fact that users
may have a preference that is different than their own. :-)


--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.


An Ony said:
Still a bit silly that it takes the OS's region settings and not by default
the invariant, but it works I guess :/


Scott said:
I find that it makes more sense to use the InvariantCulture instead of
en-US, because the InvariantCulture won't change (it's invariant).

Ok, the US one won't change either, but you never know.

scott


Michael (michka) Kaplan said:
Actually, when you convert it to a string, use the ToString method and use
the one that accepts a CultureInfo. Just pick the CultureInfo for en-US
rather than using Dutch.


--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.


Oh I can't believe it, my OS is in Dutch, very annoying
and now this:

double a = 0.8;
Console.WriteLine(a);

outputs: 0,8
yes! a comma!!! argh!! that's all very neat, but in order to use my output
with another program I need to have a dot and not a comma!!
Am I going to change them manually every time to a . or can I say
somewhere
to use a "." and not a ","? Probably changing it in the OS's
localizations,
but I'd like to leave that alone.
 
Michael,

Before I disagree with you, let me state that I completely agree with
you. It is the programmer's responsibility to take account of a
user's settings (culture) when interacting with that user. However.
I find, after writing many web apps, that like some clients request
modules they never use, some users do not set their language in the
browsers. I get users asking why their numbers look like 123.45
instead of 123,45 (I live in belgium). On my own computer these
values are not set-- Microsoft does not have a culture en-BE (english
speaking in belgium). Just to add to this problem, when converting
numbers to strings, to put in a databases for example, an additional
concern is raised: does the db expect the IV representation of the
number or the current cultural representation (and if the cultural,
then certainly not the current (dotnet) thread, but it's own thread).
We also have the additional load of clients asking (in belgium) for an
all-english application. So what culture do you set?

As with pass by value/reference, this topic is as clear as mud: it
confuses beginners and for all others it seems like a work around.
There seems to be no way to create an app without (somewhere)
double.ToString(someCulture).

Scott

Michael (michka) Kaplan said:
Actually, the normal default is to use the user's preferences. This has been
true f every version of Windows and the .NET Framework and is only
non-intuitive to developers who do not take into account the fact that users
may have a preference that is different than their own. :-)


--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.


An Ony said:
Still a bit silly that it takes the OS's region settings and not
by
default
the invariant, but it works I guess :/


Scott said:
I find that it makes more sense to use the InvariantCulture instead of
en-US, because the InvariantCulture won't change (it's invariant).

Ok, the US one won't change either, but you never know.

scott


message Actually, when you convert it to a string, use the ToString method
and use
the one that accepts a CultureInfo. Just pick the CultureInfo for
en-US
rather than using Dutch.


--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.


Oh I can't believe it, my OS is in Dutch, very annoying
and now this:

double a = 0.8;
Console.WriteLine(a);

outputs: 0,8
yes! a comma!!! argh!! that's all very neat, but in order to use
my output
with another program I need to have a dot and not a comma!!
Am I going to change them manually every time to a . or can I say
somewhere
to use a "." and not a ","? Probably changing it in the OS's
localizations,
but I'd like to leave that alone.
 
In my apps, I often found it instructional to have a "help" dialog that
showed samples of all of the different formats that the apps uses -- that
way people always know what they are getting. That form can even include
info on how to change the settings if they want to change it.

Once I started proactively doing that, I never received complaints from
users about the settings I used. I even managed to educate a few users about
their settings! :-)


--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.


Scott said:
Michael,

Before I disagree with you, let me state that I completely agree with
you. It is the programmer's responsibility to take account of a
user's settings (culture) when interacting with that user. However.
I find, after writing many web apps, that like some clients request
modules they never use, some users do not set their language in the
browsers. I get users asking why their numbers look like 123.45
instead of 123,45 (I live in belgium). On my own computer these
values are not set-- Microsoft does not have a culture en-BE (english
speaking in belgium). Just to add to this problem, when converting
numbers to strings, to put in a databases for example, an additional
concern is raised: does the db expect the IV representation of the
number or the current cultural representation (and if the cultural,
then certainly not the current (dotnet) thread, but it's own thread).
We also have the additional load of clients asking (in belgium) for an
all-english application. So what culture do you set?

As with pass by value/reference, this topic is as clear as mud: it
confuses beginners and for all others it seems like a work around.
There seems to be no way to create an app without (somewhere)
double.ToString(someCulture).

Scott

Michael (michka) Kaplan said:
Actually, the normal default is to use the user's preferences. This has been
true f every version of Windows and the .NET Framework and is only
non-intuitive to developers who do not take into account the fact that users
may have a preference that is different than their own. :-)


--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.


An Ony said:
Still a bit silly that it takes the OS's region settings and not
by
default
the invariant, but it works I guess :/


"Scott" <[email protected]> schreef in bericht
I find that it makes more sense to use the InvariantCulture instead of
en-US, because the InvariantCulture won't change (it's invariant).

Ok, the US one won't change either, but you never know.

scott


message Actually, when you convert it to a string, use the ToString method
and use
the one that accepts a CultureInfo. Just pick the CultureInfo for
en-US
rather than using Dutch.


--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.


Oh I can't believe it, my OS is in Dutch, very annoying
and now this:

double a = 0.8;
Console.WriteLine(a);

outputs: 0,8
yes! a comma!!! argh!! that's all very neat, but in order to use
my output
with another program I need to have a dot and not a comma!!
Am I going to change them manually every time to a . or can I say
somewhere
to use a "." and not a ","? Probably changing it in the OS's
localizations,
but I'd like to leave that alone.
 
Back
Top