473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Country specific decimal.parse

Following problem:

On a german computer system I am developing a program for international computer systems,

and I want my programm always to run in the same way.

There's a difference in numbers, we use "," instead of "." and "." instead of ",". (Don't know why!!!)

The method decimal.parse tries to handle that, so when you are using it on a german system,

it seems to handle commas as dots and dots as commas, what I don't want it to do.

I am checking for the length of a number, and if it is bigger then 100,000 an error should get thrown.

But 2 digits are allowed. The problem now is, that when someone enters

90,000.39 it sems to cut out the dot, so when I parse it, it gets the number 9,000,039

which is way to big, and an error gets thrown even though it shouldn't.

What can I do to prefend that???

thx,

Stefan

Nov 20 '05 #1
3 2268
Hi Stefan,

You could use ToString methods (Insert, Replace, etc.) to parse it as a string and/or insert the "." and "," manually.

You might use this just as a last resort-or at least after you do all your calculations-because it will be much slower than treating it as a number. Also, this way would bypass your globalization settings, so that might be as preferable.

Eric
"Stefan Richter" <sp**@spammenot.com> wrote in message news:c8***********@otis.netspace.net.au...
Following problem:

On a german computer system I am developing a program for international computer systems,

and I want my programm always to run in the same way.

There's a difference in numbers, we use "," instead of "." and "." instead of ",". (Don't know why!!!)

The method decimal.parse tries to handle that, so when you are using it on a german system,

it seems to handle commas as dots and dots as commas, what I don't want it to do.

I am checking for the length of a number, and if it is bigger then 100,000 an error should get thrown.

But 2 digits are allowed. The problem now is, that when someone enters

90,000.39 it sems to cut out the dot, so when I parse it, it gets the number 9,000,039

which is way to big, and an error gets thrown even though it shouldn't.

What can I do to prefend that???

thx,

Stefan

Nov 20 '05 #2
Hi Stefan,

That comma it is not only Germany, that is all the same in the EU with the exception for the UK, however that country is very slowly accepting the European standards, they have only for a short while the decimal currency and the metric standard.

The currency signs are set by Microsoft accoording the globalization settings, I advise you to keep it that way, because it can give you a lot of trouble when you change that and have no benefits when that will be probably more complete in future.

However with the String formats as "dd - MM - yyyy" for dates, you have when your program is for Europe as far as I know to do nothing (the UK are using that as well) however when you want to use that in the US it is "MM - dd-yyyy"

The same you have to do when you are using string formats with decimal dots and comma's.

However than even for every country in the EU separatly because there is no globalization EU as far as I have seen and the UK has in that the same as the US. (Or let us say the US the same as the UK, which will be probably historical more right.)

I hope this clears this a little bit?

Cor

Nov 20 '05 #3
* "Stefan Richter" <sp**@spammenot.com> scripsit:
[...]

Please post in 'text/plain' format in future.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Patrick De Ridder | last post by:
If a program works with decimal points the system country setting requires commas as a decimal separator the number of decimals = 2 then two positions are added to the numbers when...
3
by: Mark | last post by:
How do you parse a currency string to a decimal? I'd like to avoid having to parse the number out, removing the $ manually. That sounds like a hack. There are times that this string will be...
3
by: sushant.bhatia | last post by:
Whats the difference between :- 1. Convert.ToDecimal(stringNumber) 2. Decimal.Parse(stringNumber) 3. decimal.Parse(stringNumber) Thanks. Sushant Bhatia
3
by: Steve Teeples | last post by:
I have a method that passes in two string objects (both numerical numbers) and a string identifying their type. public bool DoCompare(string num1, string num2, string theirType) { System.Type...
2
by: probashi | last post by:
Hi, I am trying to the following: String s = "( 54.05)"; decimal d = decimal.Parse(s); when s = "( 54.05)" I what the value -54.05 and s = " 54.05" I what the value 54.05
3
by: Brenny | last post by:
Hello I'm developing a project by using access database and there is a table(Table1) and it has a field(ml_mik) this is the decimal field. I'm taking a value from windows form as a decimal...
1
by: Mythran | last post by:
Dim value As Decimal = 1234.56 Dim format As String = _ "Positive $#,##0.00;Negative $#,##0.00;" Dim s As String = value.ToString(format) Dim d As Decimal = Decimal.Parse(s) The last line...
6
by: Melissa | last post by:
Initially the form is loaded using ASP and HTML and the ü codes display the characters correctly. I have the values stored in a javascript array so that I can more easily and dynamically change...
5
by: Mike Schilling | last post by:
I want to write some C# that converts between floating-point numbers and strings in a non-locale-specific way. That is, I want decimal points always to be ".", etc. The simple overloads of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.