Basically, I have this really simple calculation:
int bTaxPrice = int.Parse(prices[wep]);
double t = double.Parse("1." + taxes);
double price = Math.Round(t * bTaxPrice);
I'll give you an example for how the calculation should work, lets say t=1.1
and bTaxPrice=1279
, then 1.1*1279 = 1406.9
, but since I'm rounding the result the price equals 1407.
For some users from another country (Denmark) that are using my C# Winforms program are experiencing a problem that causes the number not to round, but to add the last 2 digits after the decimal point.
Our result for the calculation above was 1407, for them it's 140690.
I read about it in the internet, and some countries have something special with there decimal point.
What is a good fix for this kind of issue?
Actually, many countries use a comma for their decimal separator.
If you want to use the dot as a separator, use the invariant CultureInfo
:
double.Parse("1." + taxes, CultureInfo.InvariantCulture);
Some countries use a comma as decimal separator. You could fix this by supplying CultureInfo.InvariantCulture
to the double.Parse
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With